CSS Position Div Over Another Div - HTML CSS CSS Layout

HTML CSS examples for CSS Layout:Position

Description

CSS Position Div Over 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">
html, body {
   height:100%;
   width:100%:
}

.container {<!--from  w ww.  j a va 2s.  c o m-->
   width:51%;
   height:100%;
   background:red;
   position:relative;
}

.container>div {
   position:relative;
   left:0;
   right:0;
}

.container>div:first-child {
   top:0;
   height:51%;
   background:blue
}

.container>div:last-child {
   bottom:0;
   height:51%;
   background:green
}
</style> 
 </head> 
 <body> 
  <div class="container"> 
   <div></div> 
   <div></div> 
  </div>  
 </body>
</html>

Related Tutorials