Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 965
Francesca Avatar asked Aug 08 '12 20:08

Francesca


Video Answer


1 Answers

I was able to solve this by actually applying CSS to the anchor. So for the anchor I would have this...

<a name="AnchorName" class="anchor"></a>

And then in the CSS I would have this...

.anchor {
   position: relative;
   top: -[number]px;
}

Note that I have noticed some inaccuracies in how far the anchor is moved in different browsers. So it might not be possible to make things align perfectly. You'd probably need some fancy jquery or something if you wanted it to be perfectly positioned.

like image 86
rgbflawed Avatar answered Sep 28 '22 02:09

rgbflawed