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

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.