CSS float div inside its container - HTML CSS CSS Layout

HTML CSS examples for CSS Layout:Float

Description

CSS float div inside its container

Demo Code

ResultView the demo in separate window

<html lang="en">
 <head> 
  <style>
.wrap {<!--  w  w w  .j av  a 2 s.com-->
   background-color:Chartreuse;
   max-width:501px;
   height:201px;
   margin:0 auto;
}

.one {
   background-color:yellow;
   height:111px;
   width:26%;
   float:left;
}

.two {
   background-color:blue;
   height:56px;
   width:51%;
   float:left;
}

.three {
   background-color:pink;
   height:36px;
   width:51%;
   float:left;
}

.four {
   background-color:WhiteSmoke;
   height:21px;
   width:26%;
   display:inline-block;
}

.five {
   background-color:OrangeRed;
   height:21px;
   width:26%;
   display:inline-block;
}
</style> 
 </head> 
 <body translate="no"> 
  <div class="wrap"> 
   <div class="one">
     One 
   </div> 
   <div class="two">
     Two 
   </div> 
   <div class="three">
     Three 
   </div> 
   <div class="four">
     Four 
   </div> 
   <div class="five">
     Five 
   </div> 
  </div>  
 </body>
</html>

Related Tutorials