Veraen
0
Q:

max width media query

/* Max-width */
@media only screen and (max-width: 600px)  {...}

/* Min-width */
@media only screen and (min-width: 600px)  {...}

/* Combining media query expressions */
@media only screen and (max-width: 600px) and (min-width: 400px)  {...}
8

  /* 
  Extra small devices (phones, 600px and down) */
@media only screen and (max-width: 600px) 
  {...} 

/* Small devices (portrait tablets and large phones, 600px and up) 
  */
@media only screen and (min-width: 600px) {...} 

/* Medium devices (landscape tablets, 768px and up) */

  @media only screen and (min-width: 768px) {...} 

/* Large devices (laptops/desktops, 992px and up) 
  */

  @media only screen and (min-width: 992px) {...} 

/* Extra large devices (large 
  laptops and desktops, 
  1200px and up) */
@media only screen and (min-width: 1200px) {...}  
7
@media (max-width: 989px) and (min-width: 768px) {}
7
CSS @media Rule

Example
Change the background color of the <body> element to "lightblue" when the browser window is 600px wide or less:

Syntax
@media only screen and (max-width: 600px) {
  body {
    background-color: lightblue;

    }
}

 
13
@media only screen and (max-width: 600px) {
  body {
    background-color: lightblue;

    }
4
<style type="text/css">
    /* default styles here for older browsers. 
       I tend to go for a 600px - 960px width max but using percentages
    */
    @media only screen and (min-width: 960px) {
        /* styles for browsers larger than 960px; */
    }
    @media only screen and (min-width: 1440px) {
        /* styles for browsers larger than 1440px; */
    }
    @media only screen and (min-width: 2000px) {
        /* for sumo sized (mac) screens */
    }
    @media only screen and (max-device-width: 480px) {
       /* styles for mobile browsers smaller than 480px; (iPhone) */
    }
    @media only screen and (device-width: 768px) {
       /* default iPad screens */
    }
    /* different techniques for iPad screening */
    @media only screen and (min-device-width: 481px) and (max-device-width: 1024px) and (orientation:portrait) {
      /* For portrait layouts only */
    }

    @media only screen and (min-device-width: 481px) and (max-device-width: 1024px) and (orientation:landscape) {
      /* For landscape layouts only */
    }
</style>
3
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
body {
  background-color: lightgreen;
}

@media only screen and (max-width: 600px) {
  body {
    background-color: lightblue;
  }
}
</style>
</head>
<body>

<p>Resize the browser window. When the width of this document is 600 pixels or less, the background-color is "lightblue", otherwise it is "lightgreen".</p>

</body>
</html>
0

  /* Set the background color of body to tan */
body {
  
  background-color: tan;
}

/* On 
  screens that are 992px or less, set the background color to blue */
@media 
  screen and (max-width: 992px) {
  body {
    
  background-color: blue;
  }
}

/* On screens that are 600px or less, 
  set the 
  background color to olive */
@media screen and (max-width: 600px) {
  
  body {
    background-color: olive;
  }
}

 
0
@media (max-height : 800px){ /* from 0 to 800 px max height applies */
  p{
    font-size:10px
  }
}
0
Max Media Query
3

New to Communities?

Join the community