Different layouts for different screen's width - HTML CSS CSS Layout

HTML CSS examples for CSS Layout:Layout

Description

Different layouts for different screen's width

Demo Code

ResultView the demo in separate window

<html>
 <head> 
  <meta name="viewport" content="width=device-width, initial-scale=1"> 
  <style id="compiled-css" type="text/css">
#dv-wrapper p {<!--from   w w w  .  j  ava  2 s  . com-->
   float:left;
   max-width:51%;
}

@media screen and (max-width: 500px)  {
   #dv-wrapper {
      text-align:center;
   }
   
   #dv-wrapper p {
      float:none;
      text-align:left;
      display:inline-block;
   }

}
</style> 
 </head> 
 <body> 
  <div id="dv-wrapper"> 
   <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi ullamcorper molestie lacus sed fermentum. Aliquam erat volutpat. Vestibulum tortor neque, ornare vitae tempor hendrerit, luctus at neque. </p> 
   <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi ullamcorper molestie lacus sed fermentum. Aliquam erat volutpat. Vestibulum tortor neque, ornare vitae tempor hendrerit, luctus at neque. </p> 
  </div>  
 </body>
</html>

Related Tutorials