My header has a fixed height of 50px. Within the body of my page, there are numerous anchor links. However, when I click on these links, the anchored content appears underneath my fixed header, causing me to lose 50px of visible content (requiring me to scroll up to view the content below the header).
Is there a way to add a margin of 50px to an anchor? The body is filled with div boxes that have margins between them, making it difficult to insert an empty div of 50px before the anchor.
HTML:
<div id="header"></div>
<div id="content">
<div class="box" id="n1"></div>
<div class="box" id="n2"></div>
<div class="box" id="n3"></div>
</div>
CSS:
#header{
height: 40px;
width: 100%;
margin: 0px;
padding: 0px;
position: fixed;
text-align: center;
z-index:2;
}
#content{
padding-top: 50px;
margin: 0px;
}
.box {
width: 80%;
margin-left: auto;
margin-right: auto;
vertical-align: top;
padding: 1.4%; /* Keep it in percent (%) */
margin-bottom: 30px;
min-height: 200px;
}