Line up 2 inline-block divs when total width is 100% - HTML CSS CSS Layout

HTML CSS examples for CSS Layout:Width

Description

Line up 2 inline-block divs when total width is 100%

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">
body {<!--from   w  ww.  ja  v a  2 s  .  c o m-->
   background-color:Chartreuse;
   margin:0;
   padding:0;
}

#main_cont {
   position:absolute;
   width:100%;
}

#sidenav {
   display:inline-block;
   float:left;
   padding:16px;
   width:16%;
   -webkit-box-sizing:border-box;
   box-sizing:border-box;
   background-color:yellow;
   -webkit-box-shadow:inset 0px 0px 6px 6px blue;
   -moz-box-shadow:inset 0px 0px 6px 6px pink;
   box-shadow:inset 0px 0px 6px 6px WhiteSmoke;
   border:2px solid OrangeRed;
}

#main {
   display:inline-block;
   float:right;
   padding:16px;
   text-align:center;
   width:86%;
   -webkit-box-sizing:border-box;
   box-sizing:border-box;
   background-color:grey;
   -webkit-box-shadow:inset 0px 0px 6px 6px BlueViolet;
   -moz-box-shadow:inset 0px 0px 6px 6px Chartreuse;
   box-shadow:inset 0px 0px 6px 6px yellow;
   border:2px solid blue;
}
</style> 
 </head> 
 <body> 
  <div id="main_cont"> 
   <div id="sidenav"> 
   </div> 
   <div id="main"> 
   </div> 
  </div>  
 </body>
</html>

Related Tutorials