Creating a 2x2 fluid layout and fill the entire screen - HTML CSS CSS Layout

HTML CSS examples for CSS Layout:Layout

Description

Creating a 2x2 fluid layout and fill the entire screen

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">
html, body {
   height:100%;
}

body {<!-- w  w  w .jav  a  2s  .  com-->
   margin:0;
}

.container {
   font-size:0;
   height:100%;
}

.item {
   font-size:17px;
   display:inline-block;
   vertical-align:top;
   width:51%;
   height:51%;
   position:relative;
   overflow:auto;
}

.content {
   position:absolute;
   left:0;
   right:0;
   top:0;
   bottom:0;
}

.item:nth-child(1) {
   background:aqua;
}

.item:nth-child(2) {
   background:lime;
}

.item:nth-child(3) {
   background:gold;
}

.item:nth-child(4) {
   background:teal;
}
</style> 
 </head> 
 <body> 
  <div class="container"> 
   <div class="item"> 
    <div class="content">
      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. Phasellus sed quam pharetra, tincidunt tortor in, pharetra nisl. Maecenas aliquam luctus mauris, vitae venenatis diam imperdiet vel. Donec tortor diam, pretium vitae nibh vitae, consectetur lacinia sem. Proin luctus facilisis volutpat. Ut semper 
    </div> 
   </div> 
   <div class="item">
     Lor 
   </div> 
   <div class="item">
     Lor 
   </div> 
   <div class="item">
     Lor 
   </div> 
  </div>  
 </body>
</html>

Related Tutorials