Anker bei Fixed Navbar treffen nicht

If you’re using a .navbar-fixed-top fixed to top navbar in Twitter Bootstrap you probably have noticed your anchor ahref links no longer line up correctly.

The easiset way to fix this is to the use the <section id="MyAnchor"> tag with a padding-top equal to the padding you’ve added to the body.

So for example if you have:

.body {
padding-top:40px
}

You will then want to add the same padding to your section CSS:

section {
padding-top:40px;
}

If the 40px gap above each section is going to mess with your design mojo you can add a negative margin-bottom. So for example:

section {
padding-top:40px;
margin-top:-40px;
}

 

Quellenangabe: https://www.servermule.com.au/help/bootstrap-anchors-fixed-nav/

Schreibe einen Kommentar

This site uses Akismet to reduce spam. Learn how your comment data is processed.