- This topic is empty.
Viewing 2 posts - 1 through 2 (of 2 total)
Viewing 2 posts - 1 through 2 (of 2 total)
- The forum ‘JavaScript’ is closed to new topics and replies.
The forums ran from 2008-2020 and are now closed and viewable here as an archive.
Home › Forums › JavaScript › Jump to anchor BUT in middle of page NOT top
I have a page which will have a number of different anchor points throughout the page (click on "Past Tense>Continuous" for example).
I can obviously jump the relevant anchor to the TOP of the page using #anchor after the URL – however, what I need to do is to jump so that the relevant anchor is in the middle of the page (or if easier, a certain specific number of pixels down from the top – either is fine.) I don’t want the section I jumped to to be hidden under the fixed positioned top section.
I’m assuming that JavaScript will have to be involved somewhere but I’m wondering if it could also be with just html and css.
Any ideas?
Ryan
Oh pure html only supports that..
Just put a name to an anchor link at the place where ever you want to jump. In the ‘href’ of the link which you want to use to move to that location, just put the ‘#<target-name>’ in the href attribute.
for example
you can obviously use jQuery to move to that location using a very slow motion effect rather than just jumping to it ;) There is a plugin available for that.. Just google for it.