Width responding to the media query - HTML CSS CSS Layout

HTML CSS examples for CSS Layout:Responsive Media

Description

Width responding to the media query

Demo Code

ResultView the demo in separate window

<html>
 <head> 
  <title>Lorem ips</title> 
  <meta name="viewport" content="width=device-width, initial-scale=1"> 
  <style id="compiled-css" type="text/css">
#box {<!--from  w w  w . j a  va 2  s. c o m-->
   margin:auto;
   background:white;
   width:100%;
}

.fake-pad {
   padding:11px;
   border:2px solid Chartreuse;
}

@media only screen and (max-width: 480px)  {
   #box {
      width:201px;
      max-width:201px;
      background:black;
   }
   
   .fake-pad {
      color:yellow;
   }

}
</style> 
 </head> 
 <body> 
  <div id="box" class="fake-pad"> 
   <div id="inner-fake-box" class="fake-pad">
     Lorem ipsum dolor sit ame 
   </div> 
  </div>  
 </body>
</html>

Related Tutorials