Let’s talk about CSS
I feel like there are two types of people. There are those who enjoy/don’t mind CSS, and those who absolutely hate CSS. When I first started learning to style on the front end, I absolutely hated it.
My issue was that when I wanted to move a div or another element around, I had a problem with individualizing it from the others. I was using margins and padding to push elements across the screen.
Grid can be an alternative solution for this issue, but to me personally, flexbox is where it’s at. Here’s how you use it.
Intro To Flexbox -
Flexbox works by organizing elements inside of whatever container you want to use flexbox on.
Here’s an example.
Let’s say I wanted to organize the way that I display these paragraph tags. I want to line them up in the middle horizontally, and space them out evenly across the container they are in.
In my CSS, I could write -
This initialized Flexbox on my container and lined my items together horizontally in the top left of the container div, and now I can now use justify-content and align-items to align them (either horizontally or vertically).
height: 50vh; (just to give the elements room to move)
Following this method of centering elements inside of their container, we can create graphs, charts, and have the freedom to create more custom layouts for a user’s experience.
While styling my options page for a project that I’m working on, I was able to make an option layout that is both dynamic and lines up consistently across other platforms.
Flexbox is both powerful and extremely organized. This is only the start of what can be done.
That’s all for now, but I hope this was a helpful tutorial to learning how Flexbox can be used to organize elements for your project. Thanks for reading.