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 trialAlfonso Nevarez
620 PointsHow do i get the Gallery to collapse to a two column structure when minimizing the window to mobile dimensions?
My gallery stays in a 3 column structure. Here is my code, please assist if you can, I would appreciate it. Thank You.
@media screen and (min-width: 480px) {
/********************* TWO COLUMN LAYOUT *********************/
#primary { width: 50%; float: left; }
#secondary { width: 40%; float: right; } }
/********************* PAGE: PORTFOLIO *********************/
gallery li {
width: 28.3333%;
}
gallery li:nth-child(3n+1) {
clear: left; }
@media screen and (min-width: 660px) {
}
1 Answer
Ian Kersey
9,318 PointsFirst thing you should do is add your gallery to the first media query, and then add the display property block to your gallery. I would also add the display property inline-block to your primary and secondary columns. Also you need to add an identifier to your gallery element, either a class or ID. just plain 'gallery' won't get you anywhere in HTML since it is not a semantic tag. Try this:
@media screen and (min-width: 480px) {
/********************* TWO COLUMN LAYOUT *********************/
primary {
display: inline-block; width: 50%; float: left; }
secondary {
display: inline-block;
width: 40%;
float: right; }
.gallery { display: block; width: 90% } }
This should give you a two column layout with the gallery underneath or on top of your columns depending on your HTML markup. If 'gallery' is an ID, simply add # in place of the period.
Hope that helps!
I also suggest checking out documentation on media queries here: https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Media_queries. Media queries can be tricky but super useful once mastered.
Alfonso Nevarez
620 PointsAlfonso Nevarez
620 PointsThank you so much for your help :)