CSS calc() function to respect bottom padding - HTML CSS CSS Property

HTML CSS examples for CSS Property:padding

Description

CSS calc() function to respect bottom padding

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">
.main-content {<!--   w  w  w . java 2 s.  c  om-->
   width:100%;
   background-color:Chartreuse;
   height:301px;
}

.header {
   background-color:yellow;
   height:51px;
}

.content:after {
   content:"";
   display:block;
   height:21px;
   width:100%;
}

.content {
   background-color:blue;
   padding-top:21px;
   padding-left:21px;
   height:calc(100% - 51px);
   overflow:auto;
   position:relative;
}
</style> 
 </head> 
 <body> 
  <div class="main-content"> 
   <div class="header">
     Lorem ip 
   </div> 
   <div class="content">
     Lorem ips 
    <div class="long-content">
      Lorem ipsum do 
     <br>Lorem ipsum do 
     <br>Lorem ipsum do 
     <br>Lorem ipsum do 
     <br>Lorem ipsum do 
     <br>Lorem ipsum do 
     <br>Lorem ipsum do 
     <br>Lorem ipsum do 
     <br>Lorem ipsum do 
     <br>Lorem ipsum do 
     <br>Lorem ipsum do 
     <br>Lorem ipsum do 
     <br>Lorem ipsum do 
     <br>Lorem ipsum do 
     <br>Lorem ipsum do 
     <br>Lorem ipsum do 
     <br>Lorem ipsum do 
     <br> 
     <button type="button">Lorem </button> 
    </div> 
   </div> 
  </div>  
 </body>
</html>

Related Tutorials