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!

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

CSS

Media Queries

http://codepen.io/pen my code works here but on a new tab as a page it won't turn red at 768px

James Barnett
James Barnett
39,199 Points

What's the link to the code challenge you are stuck on?

13 Answers

body { font: 1.1em/1.5 sans-serif; } .wrap { width: 85%; margin: auto; } h1 { font-size: 3em; } p { margin-bottom: 1.5em; }

/* ========================================================================== Media Queries ========================================================================== */

@media screen and (max-width: 768px) { body { background: #FF6347; color: #FFF; } }

when i make my page smaller on Mozilla or chrome it won't work when I make the page 768px or smaller. Though it works perfectly in codepen

what css I posted is where i am in the video but nothing happens outside of codepen

James Barnett
James Barnett
39,199 Points

Your code works just fine outside of codepen.

Post the HTML & CSS you are working on outside of codepen.

Nothing happened I tried that. I've tried both Firefox and Chrome. The only that is working for me is codepen.

that is the final project. Im still on the first step.

I now have the extension for chrome and there is no new colors for my page. What the heck!!

James Barnett
James Barnett
39,199 Points

This works for me

<!DOCTYPE html>
<html>
<head>
<style>
    .wrap {
        width: 85%;
        margin: auto;
    }
    @media screen and (max-width: 768px) and (min-width: 481px) {
        body { background: #FF6347; }
    }
     @media screen and (max-width: 480px) {
        body { background: #4682B4; }
     }
     @media screen and (min-width: 1000px) {
        .wrap { width: 700px; }
     }
</style>
</head>
<body>
    <div class="wrap">
        <h1>Hi There!</h1>
        <p>
            Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi lectus ante, luctus vel euismod ut, suscipit quis ligula. Vestibulum augue ante, semper sit amet congue non, faucibus sit amet lacus. Nam augue est, euismod ac gravida in, mattis ut felis. Ut tincidunt posuere laoreet.
        </p>
        <p>
            Maecenas lobortis porttitor nisi, quis congue neque porta at. Donec interdum arcu eu ante semper nec venenatis ipsum dignissim. Vestibulum ultricies mi quis lectus suscipit fermentum. Aliquam commodo, neque in viverra ullamcorper, augue metus aliquet diam, sit amet condimentum lectus 
        </p>
    </div>
</body>
</html>
body {
    font: 1.1em/1.5 sans-serif;
}
.wrap {
    width: 85%;
    margin: auto;
}
h1 {
    font-size: 3em;
}
p {
    margin-bottom: 1.5em;
}

/* ==========================================================================
       Media Queries
   ========================================================================== */

@media screen and (max-width: 768px) {
    body {
        background: #FF6347;
        color: #FFF;
    }
}

one big thing i can tell is that my header isnt even the same location as in the video, mine is smaller and on the top left corner. His is closer to the middle and much larger.

For goodness sake Can Someone Help Me!!!!!!! Nothing is working.

well downloaded the safari browser and guess what. Not working there either. What a great surprise.

Is there a moderator on or someone who works for teamtreehouse that does css that can help me? I've been waiting for two days and no freaking help

Guil Hernandez
STAFF
Guil Hernandez
Treehouse Teacher

Hey Scott Dietze,

Your code snippet and CodePen are correct, and they're working exactly as they should be. Based on some of your comments, my only assumption is that your CSS isn't linking correctly.

Where are you writing your CSS? If it's in the HTML file, is your CSS inside a <style> tag like in James' example?

If your CSS is in an external file, check the path to your CSS file in the <link> tag. If you're not sure, please post a screenshot and I'll take a look.

Hope this help. :)

I am using an exact download from the project/video and I watch the video and follow along with you but when I decrease the window nothing happens in the color change. I don't do anything different from the video. The codepen works just as well but not on a new tab or even complete new window.