I have three big component. Two of thes takes something like 1/3 of the screen and my goal is to present them at the horizontally from left to right.
When just putting them like in the code I added, they presented one after another Vertically which causing the uder to scroll down to find them. How can I present them in horizontally on the screen ? (I tried a couple of things with css with no success).
This is the return method, the Tables component contains two different tables inside of it:
return (
<div>
{title} <Chat />
<Tables/>}
</div>
);
To align div horizontally, one solution is to use css float property. But a better solution is to to use CSS display:inline-block on all divs which needs to be aligned horizontally and place them in some container div.
Just use flexbox, set the container CSS to have display: flex this will put everything on the same line.
Open the component's file and start editing away. Then you need to edit your styles, so you also navigate to your styles folder, find the button and open that. Now the component is updated, the tests are broken and some stories need to be updated. You navigate to those respective folders and open tests/button.
You should take a look at flexboxes !
As you probably know, React lets you create component, so you can style them just like html elements with flexboxes.
Definitely give this article a read!
Edit: EXAMPLE
HTML:
<div class="flexbox-container">
<div>Element1</div>
<div>Element2</div>
<div>Element3</div>
</div>
CSS:
.flexbox-container {
display: flex;
flex-direction: row;
}
This will align your elements horizontally with even spacing! Try playing with the container's margins and justify-elements to align elements.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With