Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Media query difference screen size in one css stylesheet

Tags:

css

Hello I have this script and I need when screen size is 1600 px background-color was red and when screen size is 1366 px background-color was black, but my code not work, media query works only 1600 px

html

<div>

</div>

css

div{
    width:100%;
    height:100%;
    background-color:grey;
}

@media screen and (max-width:1366px){
    div{
        background-color:black;
    }
}

@media screen and (max-width:1600px){
    div{
        background-color:red;
    }
}
like image 402
Val Do Avatar asked Oct 01 '22 00:10

Val Do


1 Answers

The second styles overwrite the first one. Change the order. It will work.

 div{
width:100%;
height:100%;
background-color:grey;
}

@media screen and (max-width:1600px){
   div
   {
    background-color:red;
   }
}

@media screen and (max-width:1366px){
   div
   {
    background-color:black;
   }
}

DEMO

like image 78
Suresh Ponnukalai Avatar answered Nov 15 '22 12:11

Suresh Ponnukalai