Search code examples
cssanchorpadding

Anchor not to top of page, but 200px down


I have an anchor on a element which makes the navigation jump to that point. However the anchor snaps it right up to the top of the viewport. Due do a fixed navigation, it's now hidden behind.

Is it possible to make the anchor not snap to the top of the viewport and instead 200px down the page?

Site here: http://www.haselden.co.uk/james/docs


Solution

  • Dirty solution for this but does work, thanks @SteveJenkins for coming up with this, though I added a tweak.

    <a name="AnchorName" class="anchor">anchor text [invisible]</a>
    
    .anchor {
       position: relative;
       top: -[number]px;
       visibility:hidden;
    }