Native scrollbars inside absolutely positioned element - HTML CSS CSS Layout

HTML CSS examples for CSS Layout:Absolute Position

Description

Native scrollbars inside absolutely positioned element

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 w  ww . j ava  2  s  .c o m-->
   position:absolute;
   left:26px;
   border:3px solid Chartreuse;
   max-height:201px;
   overflow-x:hidden;
   overflow-y:auto;
}

.container.one {
   top:26px;
}

.container.two {
   top:251px;
   overflow:auto;
   box-sizing:border-box;
   -moz-box-sizing:border-box;
}

.item {
   padding:6px;
   border:3px solid yellow;
   width:100%;
}

.wrapper {
   padding-right:16px;
}
</style> 
 </head> 
 <body> 
  <div class="container one"> 
   <div class="item">
     Lorem ipsum d 
   </div> 
   <div class="item">
     Lorem ipsum d 
   </div> 
   <div class="item">
     Lorem ipsum d 
   </div> 
   <div class="item">
     Lorem ipsum d 
   </div> 
   <div class="item">
     Lorem ipsum d 
   </div> 
  </div> 
  <div class="container two"> 
   <div class="wrapper"> 
    <div class="item">
      Lorem ipsum d 
    </div> 
    <div class="item">
      Lorem ipsum d 
    </div> 
    <div class="item">
      Lorem ipsum d 
    </div> 
    <div class="item">
      Lorem ipsum d 
    </div> 
    <div class="item">
      Lorem ipsum d 
    </div> 
    <div class="item">
      Lorem ipsum d 
    </div> 
    <div class="item">
      Lorem ipsum d 
    </div> 
    <div class="item">
      Lorem ipsum d 
    </div> 
    <div class="item">
      Lorem ipsum d 
    </div> 
   </div> 
  </div>  
 </body>
</html>

Related Tutorials