Float:left, keep text in own column - HTML CSS CSS Layout

HTML CSS examples for CSS Layout:Column Layout

Description

Float:left, keep text in own column

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

.f1{<!--from  w w  w  .  ja va  2 s . c  o  m-->
   background:pink;
   display: table-cell;
   width: 50px;
}
.f2, .f2b{
   background:yellow;
   display: table-cell;
}
.f2b{width:70px}
.clear{clear:both}
#page1 {width:250px;}
#page2 {width:110px; display: table; }


      </style> 
 </head> 
 <body> 
  <p class="clear">test</p> 
  <div id="page1"> 
   <div class="f1">
     float 1 
   </div> 
   <div class="f2">
     float 2 and long 
   </div> 
  </div> 
  <p class="clear">&nbsp;</p> 
  <p class="clear">test</p> 
  <div id="page2"> 
   <div class="f1">
     float 1 
   </div> 
   <div class="f2">
     float 2 and long 
   </div> 
  </div> 
  <p class="clear">&nbsp;</p> 
  <p class="clear">test</p> 
  <div id="page2"> 
   <div class="f1">
     float 1 
   </div> 
   <div class="f2b">
     float 2 and 
    <br> long 
   </div> 
  </div>  
 </body>
</html>

Related Tutorials