1

I tired many ways, but I can't get this media query to work.
"#Content" just doesn't change left position when I resize the window !
must be a way to make it run correctly !
Here's the code:

index.html

<!DOCTYPE html>
<html>
    <head>
        <link rel="stylesheet" href="style.css" type="text/css" media="screen" />
        <title>index</title>
    </head>
    <body>   
        <div id="layout">
            <div id="fixed-sidebar">
            </div>
            <div id="content">  
                content to make error visible ! 
            </div>
        </div>
    </body>
</html>

style.css

* { 
    -moz-box-sizing: border-box;
    -webkit-box-sizing: border-box;
    box-sizing: border-box;
}

#layout { 
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
}

#fixed-sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: 460px;
    background-color: rgb(33, 40, 46);
    overflow: hidden;
    padding: 20px;
    color: white;
}

#content {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 460px;
    overflow-y: scroll;
    padding: 20px;
    background-color: lightgrey;
}

@media screen and (min-width: 1151px) {
    #fixed-sidebar { width: 460px; }
    #Content {  left: 460px; }
}

@media screen and (max-width: 1150px) and (min-width: 700px) {
    #fixed-sidebar { width: 40%; }
    #Content { left: 40%; }
}

Here is a jsfiddle: http://jsfiddle.net/X3U2f/1/

What I'm doing wrong ? :/
(PS: I tried to put them important but still ignoring left position !)
Thank you

Adrift
  • 58,167
  • 12
  • 92
  • 90
Aziz Mat
  • 69
  • 2
  • 5

1 Answers1

1

"What I'm doing wrong ? :/ "

You're using a capital 'C' for the ID within the @media rules, but class and ID attribute values are case-sensitive in HTML, so you'll need to change #Content to #content:

@media screen and (min-width: 1151px) {
#fixed-sidebar { width: 460px; }
#content {  left: 460px; }
}

@media screen and (max-width: 1150px) and (min-width: 700px) {
#fixed-sidebar { width: 40%; }
#content { left: 40%; }
}

http://jsfiddle.net/X3U2f/

Community
  • 1
  • 1
Adrift
  • 58,167
  • 12
  • 92
  • 90