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.
Richard Verbraak7,726 Points
Can anyone help me explain media queries and Bootstrap?
I'm confused as to how adding col-sm resizes the columns to a one column layout in smaller devices/screens.
I didn't completely understand media queries earlier with min-width and max-width. It didn't really click for me. So if someone could explain this a bit better I'd appreciate it.
I'm guessing when you use .col it sets columns to auto and when using .col-sm it says that the columns that are rendered on screens below 576px, have their width not set to auto, but to a width predefined in Bootstrap.
I just don't get what the underlying code is with sm and md prefixes. How and why do the columns resize to a one column layout automatically when appling that prefix.
Steven Parker217,533 Points
It sounds like you already suspect that the secret to the way the Bootstrap classes work is that they are implemented using media queries. That's all handled "behind the scenes" for you so all you do is choose the classes. You could read the Boostrap code, but I don't recommend it because it is extensive and extremely dense.
I think of Bootstrap as a class-driven styling package in a "black box". If you're really curious you can read the code and/or peek with the browser dev tools. But I find it most useful by just following the API instructions and "leaving the box shut".