3

I'm using Bootstrap with the Slate theme here: http://bootswatch.com/slate/

When jumping to different anchors on the same page, it's offset and doesn't go to the exact content section it should (or not display right).

For example: http://bootswatch.com/slate/#nav

This is intended to jump to the "Navs" section and it almost does, but it's slightly offset down and you cannot see the title.

I'm experiencing the same issue on my own site with this theme, how can I fix this anchor issue?

I'm doing the basic:

<a href="#nav">Jump to Nav</a>

...

<a id="nav">Navs</a>
JBurace
  • 5,123
  • 17
  • 51
  • 76
  • It's jumping to right position, the top fixed menu is covering the title so you can't see it. You must put your anchors some place above the title so that menu won't be covering them. – Wilq Nov 26 '13 at 19:22
  • @Wilq I've tried that in my own work, I had a div I wanted to jump to so I created a new anchor above it in the HTML and it didn't help at all. Any tips in specific? – JBurace Nov 26 '13 at 19:26
  • try adding `id="nav"` at your `class="row"` div where Navs header is placed and removing it from `h1` element – Wilq Nov 26 '13 at 19:31

3 Answers3

4

Try wrapping an <a> around the element you want to skip to, like this answer suggests - e.g.

<a href="#nav">Jump to nav</a>

<a id="nav">
    <h1 style="padding-top: 50px; margin-top: -50px;">Test</h1>
    <!-- Offsets the fixed navbar -- just an example, this should be in CSS -->
</a> 
Community
  • 1
  • 1
user3142418
  • 372
  • 1
  • 7
3

Put you anchor above the bootstrap "row" class. Something like this, it worked for me.

    <a id="nav"></a>
    <div class="row">
      <div class="col-lg-12">
        <div class="page-header">
          <h1>Navs</h1>
        </div>
      </div>
    </div>
wesley
  • 553
  • 1
  • 4
  • 9
  • I have a `

    Header

    content` code I want to anchor to. I added the `` right before that, but it didn't help at all.
    – JBurace Nov 26 '13 at 20:24
  • NOTHING else would work for me... but this did. Thanks @wesley ! wesley's answer depends on having a "row" element... like I do. I had the problem where I couldn't move to an anchor point **at all** because of how all the divs and rows were setup. This solved it. – mystic cola May 27 '16 at 14:26
1

I couldn't get the other answers to work; may have been my error. But I liked the solution offered by Jan to the question offsetting an html anchor to adjust for fixed header; I just had to tweak it because bootstrap buried my anchors in paragraphs.

So I made the style as follows:

  p a.anchor {
    display: block; 
    position: relative;
    top: -50px; 
    visibility: hidden;
  }

and made all my anchors class="anchor". This is clean and just one parameter to update.

Community
  • 1
  • 1
John G
  • 41
  • 3