Positioning two div elements with one centered - HTML CSS CSS Layout

HTML CSS examples for CSS Layout:2 Column

Description

Positioning two div elements with one centered

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 {<!--from  ww  w  . ja v a  2s.co  m-->
   text-align:center;
   position:relative;
}

.center {
   width:100px;
   height:100px;
   background-color:Chartreuse;
   display:inline-block;
}

.right {
   width:100px;
   height:100px;
   background-color:yellow;
   position:absolute;
   top:0;
   left:calc(51% + 51px);
}
</style> 
 </head> 
 <body> 
  <div class="container"> 
   <div class="center"></div> 
   <div class="right"></div> 
  </div>  
 </body>
</html>

Related Tutorials