Grow your CSS skills. Land your dream job.

Jump to anchor BUT in middle of page NOT top

  • # September 19, 2009 at 9:49 pm

    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

    # September 20, 2009 at 2:20 pm

    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

    Code:

    blah
    blah
    blah

    yadda
    yadda
    yadda
    Go to welcome area

    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.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".