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

Alex G.
Alex G.
10,329 Points

I see CSS Flexbox as a way to replace the Media Queries. What do you guys think?

I see CSS Flexbox as a way to replace the Media Queries. What do you guys think?

Simon Duchaine
Simon Duchaine
14,441 Points

For layouts, you could indeed see it that way, Flexbox is really powerful for layouts.

But you could still need sometimes media queries if you want, for instance, to hide or show some elements depending on the screen size or to modify parts of your design for mobile or desktop.

As you can see, media queries were used at first for mobile-first layout but it was not created only for layout. You could see media queries as a way to have independent designs for each screen size.

1 Answer

Well no media queries are still required. When you set a div or page element as flex all children are flex items and the default behaviour is that the items are no longer stacked but displayed in a line. However to stack them for a mobile first menu for example you need a media query.