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 trialYusef Andrews
3,982 PointsIs Flexbox meant to replace the media query method for response design?
I've googled this question but can't seem to find a direct answer. It seem as though this and the media query method do some what of the same thing.
1 Answer
Máté Végh
25,607 PointsHi Yusef,
I don't know what you mean exactly by replacing, but:
- Flexbox can't do the exact same things that media queries can and it's also true vice versa, therefore it's not meant to replace media queries.
- There are some cases however, where you can skip using media queries because of the abilities of flexbox. For example you can create responsive grids without media queries (I assume you meant this rather than replacing media queries entirely).
I see many advantages of using flexbox instead of media queries, but I see two main issues with this method:
- Browser support – media queries have much larger support than flexbox
- Items on the last line flexing full width instead of having a consistent width like the other items. Here's what I mean: http://codepen.io/mattvegetable/pen/QEqBkG
Yusef Andrews
3,982 PointsYusef Andrews
3,982 PointsI see, I'm a little confused as to why flexbox is necessary. I did how watch another video here on treehouse where they indirectly said flexbox is a better method to using floats. Is that the point of flexbox?
Máté Végh
25,607 PointsMáté Végh
25,607 PointsSorry, I just realized I may have overcomplicated your question a bit :)
While the floated layout method is a hacky, not so elegant solution, flexbox doesn't require any clearfix hack or such workaround. But that's just one of the many benefits of flexbox.
Here are some more:
There are many great articles about flexbox out there, but this one is one of the most popular ones. You should definitely read through if you haven't already: https://css-tricks.com/snippets/css/a-guide-to-flexbox
Yusef Andrews
3,982 PointsYusef Andrews
3,982 PointsPerfect, I just finished the flexbox course and it amazing. Just wish it worked for some of the older IE browsers
Máté Végh
25,607 PointsMáté Végh
25,607 PointsI know, it's a big pain. You should definitely create fallbacks or not use flexbox at all if you want to optimize a website for older versions of IE. Also IE 10 and 11 are just partially supporting it, which means that it often produces very weird bugs. It can cause issues even in browsers that fully supports flexbox, so you really need to be careful.