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 trialKailash 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
Richard Chapman
25,836 PointsMake sure to add the 'Background-color' tag when altering the colour of your background :
@media screen and (min-width: 480px) { body{ background-color: navy; } }
Melisa Hamilton
11,729 PointsTry taking out the 'screen'. It should be @media { { } }
Marco Otto
5,342 Pointsyes 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
9,510 PointsI 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
3,087 PointsThanks for the help but I already solved the issue :-)
Rodrigo Teixeira
1,417 PointsJust 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
Kailash Seshadri
3,087 PointsKailash Seshadri
3,087 PointsIt works, thank you very much!