Top banner blocking anchor links



  • Erik Johnson

    As a workaround, I can create a manual anchor link, set a few lines higher than the header — but that means source code for each anchor, and if I adjust the text of an article the anchor might not head to the right spot anymore. 

  • Maggie Ungerboeck

    Hi Erik,

    You aren't the only one that has this same problem - we have it too. We use the same workaround that you do. Interested to see if anyone else has been able to find a better solution.



  • Brett Bowser
    Zendesk Community Manager

    Hi Erik,

    Great question!

    I'm going to get this post added to our monthly Community Roundup to help get more eyes on your question.

    Cheers :)

  • Erik Johnson

    Thank you!

  • Nicky Lilja

    I have the same problem!  Would be great to get a solution. :)

  • Floris Bijker

    It's because your Nav bar has a CSS property of "position: fixed". Block elements can have this, and it means they are detatched from the normal flow of your document, and get fixed to the viewport instead. So your page kind of disappears behind it. 

    I guess there's a few solutions for it. Easiest would be this one:

    Or you could go the jQuery route with this:

    Hope that helps.

  • Erik Johnson

    Thanks Floris! I just today found a solution that worked, and it's along the same lines, I think. Just CSS instead of jQuery. 

    Our Zendesk rep did some digging, and found this post, which had the answer:

    The solution posted there did not help, because it moved the header itself and stuffed it somewhere else in the text. 

    But by combining :target with one of the comments on that post, I found a solution that worked beautifully.

    :target {
    padding-top: 79px;
    margin-top: -79px;
    display: inline-block;

    If I understand what that's saying (it's likely I don't), it's giving anchor link targets a padding that's the height of our top level banner (≈80px). 

    Whatever it's saying, slapping that into style.css worked immediately. I just need approval to move it from my little sandbox theme to production and we'll be off and running. 

    Hope this helps other folks!

  • Duane Knudsen

    Erik, this is genius!!! Works perfect, just copy/pasted to the very end of css. Already moved to production. This has been a bit of a sore spot for us and I've been looking for this exact solution.


  • Sean Needham

    Thank you Erik!!

    This worked for us too!!

    I really appreciate the help. Have a great day :)

  • Nicole Saunders
    Zendesk Community Manager

    @... if you would consider posting your answer as a tip in our User Tips & Tricks section, that would make it easier for users to find, and we'll send you a small thank you gift for doing so. :)


Please sign in to leave a comment.

Powered by Zendesk