Positioning divs with unknown width - HTML CSS CSS Layout

HTML CSS examples for CSS Layout:Position

Description

Positioning divs with unknown width

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 {<!--   www . j  a va2s  .  c  o  m-->
   position:relative;
   left:31px;
   top:31px;
   width:401px;
   height:51px;
   outline:2px solid red;
}

#left {
   float:left;
   display:inline-block;
   height:51px;
   outline:3px solid blue;
}

#right {
   display:block;
   overflow:hidden;
   height:51px;
   outline:3px solid green;
}
</style> 
 </head> 
 <body> 
  <div id="container"> 
   <div id="left">
     Lorem ipsum dolor 
   </div> 
   <div id="right"></div> 
  </div>  
 </body>
</html>

Related Tutorials