make a fluid grid with fixed width columns - HTML CSS CSS Layout

HTML CSS examples for CSS Layout:Column Layout

Description

make a fluid grid with fixed width columns

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">

.container {<!--from  ww w  .  ja v a2  s. c  om-->
   width: 960px;
   margin: auto;
   overflow: auto;
}
@media only screen and (max-width : 960px) {
   .container {
      width: 640px;
   }
}
@media only screen and (max-width : 640px) {
   .container {
      width: 320px;
   }
}
.block {
   width: 300px;
   height: 300px;
   float:left;
   margin: 10px;
   background: #ccc;
}


      </style> 
 </head> 
 <body> 
  <div class="container"> 
   <div class="block"></div> 
   <div class="block"></div> 
   <div class="block"></div> 
   <div class="block"></div> 
   <div class="block"></div> 
   <div class="block"></div> 
  </div>  
 </body>
</html>

Related Tutorials