Adjusting HTML Anchor for Fixed Header Using CSS
When working with fixed headers, it's common to encounter situations where anchors linked to content within the page jump to the top of the page, obscuring content behind the header. To resolve this issue, one can adjust the anchors' offset to align with the bottom of the fixed header.
One effective solution involves using CSS:
<a class="anchor">
a.anchor { display: block; position: relative; top: -250px; visibility: hidden; }
This adjustment ensures that the anchor still links to the correct content, while compensating for the hidden portion behind the header. Note that the visibility: hidden; property is used to prevent the anchor from being visually visible.
The above is the detailed content of How Can I Fix Anchors Jumping Behind a Fixed Header in CSS?. For more information, please follow other related articles on the PHP Chinese website!