I am using the Bootstrap 5 navbar with fixed-top. I basically took the template from the bootstrap website:
https://getbootstrap.com/docs/5.3/components/navbar/#toggler
On smaller screens you get the Toggle-Item. When you click it, it opens up normally. But when you click an item, it doesn’t close.
I provided a basic example here:
https://jsfiddle.net/ozLm3qs1/
On #ref2 I added the
data-bs-toggle="collapse"
data-bs-target=".navbar-collapse.show"
to the a tag. Then the menu closes when you click #ref2, but the link doesn’t work anymore.
In Bootstrap 4 it just worked fine, so when you click an item in the Toggle-Menu, the menu will close.
Does anyone have a working example with both working link and closing the menu?
user24699140 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.