CSS positive padding with negative margin - HTML CSS CSS Property

HTML CSS examples for CSS Property:padding

Description

CSS positive padding with negative margin

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">
html, body {
   margin:0;
}

body {<!--from w w w.j  a v  a2s .c  om-->
   padding-top:51px;
}

.fixed-navbar {
   position:fixed;
   top:0;
   width:100%;
   height:51px;
   background-color:Chartreuse;
}

.some-really-tall-content {
   height:5001px;
   background-color:yellow;
}

#interesting-content {
   padding-top:51px;
   margin-top:-51px;
}
</style> 
 </head> 
 <body> 
  <div class="fixed-navbar">
    Lorem ipsum dol 
  </div> 
  <a href="#interesting-content">Lorem ipsum dolor sit amet, conse</a> 
  <p class="some-really-tall-content">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi u</p> 
  <h2 id="interesting-content">Lorem ipsum dolor sit am</h2> 
  <p>Lorem ipsum</p> 
  <p class="some-really-tall-content">Lorem ipsum dolor sit amet</p>  
 </body>
</html>

Related Tutorials