Fix menu with bootstrap after scrolling down

Asked

Viewed 3,282 times

0

I’m using bootstrap in my code

Has a class in the nav of bootstrap fixing the nav in the top

navbar-Fixed-top

But I want the nav just stay fixed when the scroll goes through it.

How do I do that?

An example: This site

2 answers

2


  • How do I install affix to my html? I can’t find

  • I don’t think it requires any installation, just copy the tag and adapt it to what it is needed, here you can find everything about affix https://www.w3schools.com/bootstrap_affix.asp

  • It’s not working. I put <nav class="navbar navbar-default" data-spy="affix-top" data-offset-top="197"> and still can’t fix @K. Chanel

  • Try it yourself on w3schools.com/bootstrap/bootstrap_affix.Asp to try it out and see how it works

  • the "offset-top" tag determines how many pixels you need to scroll to the top and what activates affix is the 'data-Spy="affix"'

1

Browser other questions tagged

You are not signed in. Login or sign up in order to post.