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 trialJason Larkin
13,970 PointsMedia query not working
@media screen and ( max-width: 768px ) { {background:#FF6347; color:white;}
}
I have been having trouble with this media query. Can someone help? Thank you in advance for any replies.
3 Answers
Paul Johnson
18,924 PointsHi Jason,
You don't have any selectors before the declaration so the browser doesn't know what you are trying to apply the rule to. If you are trying to change the background and color of the body for example it should be
@media screen and (max-width: 768px) {
body {
background: #FF6347;
color: white;
}
}
Hope this helps.
Nicolas Degrandy
11,529 PointsHey Jason, it looks like you're not assigning the background or colour to anything:
Perhaps you want to try this:
@media screen and ( max-width: 768px ) { .containerClass { background:#FF6347; color:white; } }
You would need to have defined the class name in your HTML code too, or select .body if that's what you're referring to as Paul suggested
Jason Larkin
13,970 PointsThank you Nicholas- that solved it!
Jason Larkin
13,970 PointsJason Larkin
13,970 PointsThank you for the code- it was the solution!