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

implementing media queries in the responsive website project

Hi, I am working on implementing media queries in the responsive website project. I have typed the code the Allison used to make the navigation scale with the "contact us" on the next row down. When I refresh my browser, it doesn't change on my page. Does anyone know what I'm doing wrong?

/* media queries */
/* iphone--------------- */
@media screen and (max-width: 480px) {
.grid_1,
.grid_2,
.grid_3,
.grid_4,
.grid_5,
.grid_6,
.grid_7,
.grid_8,
.grid_9,
.grid_10,
.grid_11,
.grid_12 {
    width: 100%;
}
#nav ul {
    margin: 5% 0;
}

#nav ul li {
float: left;
margin: 5% 0;
}
#nav ul li.about {
    width: 20%;
}    
#nav ul li.pricing {
    width: 50%;
}
#nav ul li.locations {
    width: 30%;
}
#nav ul li.contact {
    width: 100%;
    margin: 0;
    font-size: 1em;

2 Answers

James Barnett
James Barnett
39,199 Points

You forgot to close 2 of your curly brackets. I've reformatted your CSS, see if you can spot where they are missing. Using a text editor with bracket matching can help you spot such things.

@media screen and (max-width: 480px) {

.grid_1,
.grid_2,
.grid_3,
.grid_4,
.grid_5,
.grid_6,
.grid_7,
.grid_8,
.grid_9,
.grid_10,
.grid_11,
.grid_12 { width: 100%; }

#nav ul { margin: 5% 0; }
#nav ul li {
    float: left;
    margin: 5% 0;
}

#nav ul li.about { width: 20%; }    
#nav ul li.pricing { width: 50%; }
#nav ul li.locations { width: 30%; }
#nav ul li.contact {
    width: 100%;
    margin: 0;
    font-size: 1em;

Hi James, Thanks for your response. It looks like I am missing the closing curly bracket for the "contact" line and missing the closing curly bracket for the entire media query. I added those in and I'm still not seeing the changes in my page. I updated the formatting to what you suggested above, and added in the two brackets that I saw were missing.

@media screen and (max-width: 480px) {
    .grid_1,
    .grid_2,
    .grid_3,
    .grid_4,
    .grid_5,
    .grid_6,
    .grid_7,
    .grid_8,
    .grid_9,
    .grid_10,
    .grid_11,
    .grid_12 {width: 100%;}

#nav ul {margin: 5% 0;}

#nav ul li a {
    -webkit-user-select: none;
}

#nav ul li {
float: left;
margin: 5% 0;
}

#nav ul li.about { width: 20%; }    
#nav ul li.pricing { width: 50%; }
#nav ul li.locations { width: 30%; }
#nav ul li.contact {
    width: 100%;
    margin: 0;
    font-size: 1em;}
}
Hunter Stewart
Hunter Stewart
11,515 Points

Make sure that you downloaded the directory for that lesson, because it does not include the same index.html file that was used in the original Build a Simple Website directory. It has a lot of changes in the markup. I made that mistake and kept thinking there was an error in my CSS.