CSS Layout How to - Set size for media queries








Question

We would like to know how to set size for media queries.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
@media only screen and (min-width: 480px) {
  body {<!--from   ww  w .j  a  va 2s.  c  om-->
    background: #030;
  }
  .menu li {
    font: 12px Verdana;
    width: 100px;
    padding-left: 10px;
  }
}
@media only screen and (min-width: 768px) {
  body {
    background: #645;
  }
  .menu li {
    font: 22px Verdana;
    width: 200px;
    padding-left: 20px;
  }
}
.menu li {
  color: white;
  font: 22px Verdana;
  text-transform: uppercase;
  display: block;
  float: left;
  border-right: 1px solid white;
  border-bottom: 1px solid white;
  width: 200px;
  padding-left: 20px;
}
</style>
</head>
<body>
  <ul class="menu">
    <li>One</li>
    <li>Two</li>
    <li>Three</li>
    <li>Four</li>
    <li>Five</li>
    <li>Six</li>
    <li>Seven</li>
    <li>Eight</li>
    <li>Nine</li>
  </ul>
</body>
</html>

The code above is rendered as follows: