Scroll content under a fixed header while respecting max-height - HTML CSS CSS Widget

HTML CSS examples for CSS Widget:Header

Description

Scroll content under a fixed header while respecting max-height

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

div {<!-- w  w w  .j av a  2s.  c  o m-->
   border: 1px solid #DDD;
}
.container {
   max-height: 150px;
   display: flex;
   flex-direction:column;
}
.header {
   height: 40px;
}
.scroll {
   max-height: inherit;
   overflow: auto;
}


      </style> 
 </head> 
 <body> 
  <div class="container"> 
   <div class="header">
     header 
   </div> 
   <div class="scroll"> 
    <div>
      scroll 
    </div> 
    <div>
      scroll 
    </div> 
    <div>
      scroll 
    </div> 
    <div>
      scroll 
    </div> 
    <div>
      scroll 
    </div> 
    <div>
      scroll 
    </div> 
    <div>
      scroll 
    </div> 
    <div>
      scroll 
    </div> 
    <div>
      scroll 
    </div> 
    <div>
      scroll 
    </div> 
    <div>
      scroll 
    </div> 
   </div> 
  </div>  
 </body>
</html>

Related Tutorials