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

break points problems in CSS

Hi. I was just wondering if anyone else is having trouble in the CSS portion of creating media breakpoints for responsive design.

I've gone over the video several times and still can't get it to work.

I have linked the stylesheet and it shows that it's linked in Dreamweaver: <link rel="stylesheet" href="css/responsive.css"> and that link resides AFTER the link to main css as instructed.

In the responsive CSS file my media query looks like this:

@media screen and (min-width: 480px) {

body {background:#999;}

}

When the browser window is not smaller than 480px it should be displaying a grey background, not white.
Any ideas on this?
Thanks.

  • Chris

1 Answer

Ian Hempsell
PLUS
Ian Hempsell
Courses Plus Student 37,036 Points

Hey Chris,

The problem is that the CSS within your @media will not take effect until the screen width is a MINIMUM of 480px.

If you want the background to be #999 on screen sizes up to 480px, you need to use MAX-WIDTH:

@media screen and (max-width: 480px) {

body {background:#999;}

}

Using MIN-WIDTH results in the CSS applying at the 480px and above, while MAX-WIDTH applies to 479px and below.

Hope that helps, Ian.