Fixed header on div with scrollbar - HTML CSS CSS Widget

HTML CSS examples for CSS Widget:Header

Description

Fixed header on div with scrollbar

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">

body {<!--  w  ww  .j a v  a 2 s  .  co  m-->
   background-color: rgb(240,240,240);
   color: rgb(60,60,60);
}
.outer {
   position: absolute;
   top: 20px;
   left: 20px;
   width: 200px;
   height: 300px;
}
.top {
   position: absolute;
   height: 30px;
   background-color: rgb(220,220,220);
   border: 1px solid rgb(200,200,200);
   box-sizing: border-box;
   padding: 5px;
   width: 100%;
}
.body {
   position: relative;
   width: 100%;
   height: 100%;
   overflow: auto;
   overflow-x: hidden;
   border: 1px solid rgb(200,200,200);
}
.content {
   background-color: white;
   position: relative;
   z-index: -1;
   margin-top: 30px;
   padding: 5px;
   font-size: 12px;
}


      </style> 
 </head> 
 <body> 
  <div class="outer"> 
   <div class="top">
     Title 
   </div> 
   <div class="body"> 
    <div class="content">
      content content content content content content content content content 
      content content content content content content content content content 
      content content content content content content content content content 
    </div> 
   </div> 
  </div>  
 </body>
</html>

Related Tutorials