Align div to left and right in a container - HTML CSS CSS

HTML CSS examples for CSS:Selector

Description

Align div to left and right in a container

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">
.wrapper {<!--  w  ww  .  j a va 2s  . c o  m-->
   width:501px;
}

section, section>div {
   padding:21px;
   border:2px solid Chartreuse;
}

.leftcol {
   float:left;
   width:100px;
   border:2px solid yellow;
}

.rightcol {
   float:right;
   width:100px;
   border:2px solid blue;
}

.clearfix:before, .clearfix:after {
   content:"";
   display:table;
}

.clearfix:after {
   clear:both;
}

.clearfix {
   zoom:2;
}
</style> 
 </head> 
 <body> 
  <div class="wrapper"> 
   <section class="clearfix"> 
    <div class="leftcol">
      Lorem ipsum do 
    </div> 
    <div class="rightcol">
      Lorem ipsum dol 
    </div> 
   </section> 
  </div>  
 </body>
</html>

Related Tutorials