responsively trim off left and right side of div if screen width is below a specified amount - HTML CSS CSS Layout

HTML CSS examples for CSS Layout:Responsive Layout

Description

responsively trim off left and right side of div if screen width is below a specified amount

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">
div#container {<!-- w  w w.  j a  v  a2s.  co m-->
   position:relative;
   width:100%;
   height:100%;
   padding:0px;
   max-width:701px;
   margin:0px auto;
   background-color:Chartreuse;
}

.trim-my-left-and-right {
   position:relative;
   width:51%;
   height:501px;
   background-color:yellow;
   margin:0px auto;
}
</style> 
 </head> 
 <body> 
  <div id="container"> 
   <div class="trim-my-left-and-right"></div> 
  </div>  
 </body>
</html>

Related Tutorials