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 trialJorge Amezcua
2,425 PointsIt dosen't work! I have tried for 1 hour and nothing! Help!
This is my code:
@media (max-width: 960px) { body { background: blue; } p { color: white; } }
@media (max-width: 480px) { body { background: darkred; } }
Am I wrong? or what happen? Thank you!
4 Answers
Jason Jones
22,155 PointsI had to add the "all and" keywords to get it to work. @media all and (max-width: 960px) ...
Christine Hendrickson
Front End Web Development Techdegree Student 5,422 PointsI tried the suggestions above and I still couldn't get this working.
Just in case someone else is struggling with this, I found the solution (for me) in another thread. Change the second entry (for dark red) to something larger than 480 - I tried 600 and this worked perfectly for me. Apparently, my browser would only shrink to a size that was larger than 480 so the change wasn't firing.
Hope this helps! Happy Coding ☺
Julianna Kahn
20,702 PointsWow, 600px! That did work, thanks.
robiny
7,334 PointsThat worked for me! Thank you! Saved me an hour of breaking my head.
Lori Moritz
Courses Plus Student 9,150 PointsI am having the same trouble, and adding the 'all and' didn't work for me.
Rouillie Wilkerson
10,419 PointsMake sure you're recognizing the body from the header. If you scroll down, then resize, you'll see that the blue and white is being applied when you reach the 960px,mark.
Phill Haines
6,333 PointsPhill Haines
6,333 PointsJason,
Thank you so much for the fix!