CSS Divs positioning two div elements in same line - HTML CSS CSS Layout

HTML CSS examples for CSS Layout:Position

Description

CSS Divs positioning two div elements in same line

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">
.DivParent<!-- w  ww .  j  a v a2  s.co  m-->
 {
   border:2px solid Chartreuse;
   padding:0;
   margin:0;
   display:table;
   width:100%;
   -moz-box-sizing:border-box;
   -webkit-box-sizing:border-box;
   box-sizing:border-box;
}

.Div1
 {
   border:5px solid yellow;
   padding:0;
   margin:0;
   display:table-cell;
}

.Div2
 {
   border:5px solid blue;
   width:100px;
   height:51px;
}
</style> 
 </head> 
 <body> 
  <div class="DivParent"> 
   <div class="Div1">
     Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi ullamcorper molestie lacus sed fermentum. Aliquam erat volutpat. Vestibulum tortor neque, ornare vitae tempor hendrerit, luctus at neque. Phasellus sed quam pharetra, tincidunt tortor in, pharetra nisl. Maecenas aliquam luctus mauris, vitae venenatis diam imperdiet v 
   </div> 
   <div class="Div2">
     Lorem i 
   </div> 
  </div>  
 </body>
</html>

Related Tutorials