Scrollbar when adding absolute position to inner div - HTML CSS CSS Layout

HTML CSS examples for CSS Layout:Absolute Position

Description

Scrollbar when adding absolute position to inner 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">
.overflow {
   width:81%;
   margin-left:11%;
   height:301px;
   overflow-y:auto;
   background:Chartreuse;
   color:yellow;
   position:relative;
}

.divwidth {<!--from  w ww  .  j  a  v  a2 s  .c  o  m-->
   width:100px;
   height:31px;
   background:blue;
   position:absolute;
   margin-left:-26px;
}
</style> 
 </head> 
 <body> 
  <div class="overflow"> 
   <p>Lor</p> 
   <p>Lor</p> 
   <p>Lor</p> 
   <p>Lor</p> 
   <div class="divwidth"> 
   </div> 
   <p>Lor</p> 
   <p>Lor</p> 
   <p>Lor</p> 
   <p>Lor</p> 
  </div>  
 </body>
</html>

Related Tutorials