Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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.