Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

CSS

Flex box and other methods.

Hi! Im wondering since, i find flexbox to be awsome, and much easier to work with than position absolute and relative.

My question is, would it be stupid to only focus on becoming a flexbox master, and ignoring the other position values?

Hi Pontus Bolmér, i'll try to answer your question.

Flexbox is a nice tool, but not the only one. In future videos, here at Treehouse, you will find another ways to do what Flexbox do, but there is no right or wrong. Each case is different, there will be times when Grids { you will study this here } will be better than Flexbox, other times Flexbox is better, and in my opinion, in 90% of the cases you can use both, and transform the combination in a nice work.

By the way: Position values as - absolute, relative, static... work different as Flexbox. You should know how to use all of this.

Hope this helps.

Happy codding.

2 Answers

jared eiseman
jared eiseman
29,023 Points

Flexbox is a WONDERFUL tool. It is important, however, to recognize that it is a tool, one of many in your toolbox. There are scenarios in which absolute/relative/fixed positions are the best for the scenario, or even necessary. The example that comes to mind initially is in the case of pseudo elements (::before and ::after). There are also times that floats might be the right choice, as they can sometimes be easier to manage gutter widths and line wrapping. CSS grids, and grids provided by various CSS frameworks are incredibly useful as well. In the case of Bootstrap 4, they even moved to using flexbox for a lot of the grid options and dropping floats.

Long story short, learn flexbox, it's great. Don't force yourself to use flexbox for every situation though, as there are other tools in the toolbox that might be better for certain applications.

Thanks for both your answers! Very nice and detailed answers!