Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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.