Results 1 to 3 of 3

Thread: Fixed html header obscures jumped to anchors

  1. #1
    Join Date
    Jul 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Fixed html header obscures jumped to anchors

    1) Script Title: Scrolling HTML bookmarks

    2) Script URL (on DD): http://www.dynamicdrive.com/dynamici...markscroll.htm

    3) Describe problem: I' am building a site with a fixed header section. Using within-page links places the jumped-to content right at the very top of the document. This is a problem to me because the fixed header obscures my anchor targets. Is there a way the Scrolling HTML bookmarks script can be modified to account for the height of the header section?

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    You just need to plan the positioning of your anchors differently to account for the height of the header.

    Say you want to scroll to here using the highlighted anchor:

    Code:
    <div><a name="myname" id="myname"></a>Some Content You want to scroll to</div>
    And say your fixed header is 200px tall. Then instead of placing the anchor there, place it about 225px earlier, example:

    Code:
    <a name="myname" id="myname"></a>
    <div>Some content that fills about 225px worth of vertical space</div>
    <div>Some Content You want to scroll to</div>
    Or, and I like this method better, put all your anchors in a container div:

    Code:
    <div class="anchors"><a name="myname" id="myname"></a></div>
    <div>Some Content You want to scroll to</div>
    And in your stylesheet put:

    Code:
    .anchors {
    	font=size: 1px;
    	height: 1px;
    	overflow: hidden;
    	position: relative;
    	top: -250px;
    }
    The browser cache may need to be cleared and/or the page refreshed to see changes.

    If you want more help, please include a link to the page on your site that contains the problematic code so we can check it out.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Jul 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thanks John. I somehow figured it out in the script. Just had to set the yoffset value to the height of the header and it works out fine.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •