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

HTML How to Make a Website Responsive Web Design and Testing Adding Breakpoints for Devices

Kailash Seshadri
Kailash Seshadri
3,087 Points

[SOLVED] background color doesn't change

@media screen (min-width: 480px) { body{ background:navy; } } background color does not change when resizing the window

4 Answers

Make sure to add the 'Background-color' tag when altering the colour of your background :

@media screen and (min-width: 480px) { body{ background-color: navy; } }
Kailash Seshadri
Kailash Seshadri
3,087 Points

It works, thank you very much!

Try taking out the 'screen'. It should be @media { { } }

Marco Otto
Marco Otto
5,342 Points

yes its navy-blue now but not "responsive" any more and I think that was the whole point of creating a responsive.css wasn't it? ;-)

Hayley Risley
Hayley Risley
9,510 Points

I had this issue too, here's the code that I used that ended up working:

@media screen and (min-width:480px) { body { background-color: navy; } }

@media screen and (min-width:660px){ body{ background-color: darkgreen; } }

Kailash Seshadri
Kailash Seshadri
3,087 Points

Thanks for the help but I already solved the issue :-)

Rodrigo Teixeira
Rodrigo Teixeira
1,417 Points

Just to add some information. Another way to solve it is to leave the media query modifications as default, without the "color" word

@media screen and (min-width: 480px) {
body {
background: navy;
  }
}

And change the main.css file.

body {
background: #fff; /* it used to be background-color */
color: #999;
}

This occurs, because the color of the background of body element was primarily set with the property background-color (in the main.css file) and the media query will only replace the same property. So it doesn't matter if it is "background" or "background-color". As long as it is the same in both the main and responsive files, it will work. =D