Positioning a div in the middle of another div - HTML CSS CSS Layout

HTML CSS examples for CSS Layout:Position

Description

Positioning a div in the middle of another div

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">
#button<!--from  ww  w.  j a v  a  2s. com-->
 {
   position:fixed;
   top:0;
   left:0;
   width:100px;
   height:100px;
   background-color:Chartreuse;
}

#plus
 {
   position:relative;
   width:51%;
   height:51%;
   top:26%;
   margin:0 auto;
   background:orange;
}
</style> 
 </head> 
 <body> 
  <div id="button"> 
   <div id="plus">
     Lor 
   </div> 
  </div>  
 </body>
</html>

Related Tutorials