Bootstrap affix doesn't change active tab


xx

The code was written by a former front-end developer at my company. After he left, I was asked to edit this page. When I was done working on the CSS, I found that the affixes that were valid before would always activate the last li element. I have tried many ways but don't know why this is happening.

Sample code:

<ul id="myNav" class="nav nav-tabs nav-stacked">
  <li><a href="#section-1">关于Speed Dating</a></li>
  <li><a href="#section-2">活动流程</a></li>
  <li><a href="#section-3">成功案例</a></li>
  <li><a href="#section-4">往期回顾</a></li>
  <li><a href="#section-5">地点</a></li>
  <li><a href="#section-6">合作伙伴</a></li>
</ul>
......
<h2 id="section-1">关于Speed Dating</h2>
<h2 id="section-2">关于Speed Dating</h2>
......

The entire code is on CodePen

xx

In the end, I found out that this is because the former marked with the attribute is data-spy="scroll" data-target="#myScrollspy"now on the div element.

I removed the body tag because the previous HTML had two bodytags, the first was set in the base template and the second was written in HTML to bind the bootstrap affix. So the bootstrap affix didn't work after I changed the second bodylabel to div.

TL, NR: This was fixed after adding the attribute data-spy="scroll" data-target="#myScrollspy"to the body element .

Related


Bootstrap affix doesn't change active tab

xx The code was written by a former front-end developer at my company. After he left, I was asked to edit this page. When I was done working on the CSS, I found that the affixes that were valid before would always activate the last li element. I have tried man

Bootstrap affix doesn't change active tab

xx The code was written by a former front-end developer at my company. After he left, I was asked to edit this page. When I was done working on the CSS, I found that the affixes that were valid before would always activate the last li element. I have tried man

Bootstrap affix doesn't change active tab

kxxoling The code was written by a former front-end developer at my company. After he left, I was asked to edit this page. When I was done working on the CSS, I found that the affix that worked before would always activate the last li element. I have tried man

Bootstrap affix doesn't change active tab

kxxoling The code was written by a former front-end developer at my company. After he left, I was asked to edit this page. When I was done working on the CSS, I found that the affix that worked before would always activate the last li element. I have tried man

Affix doesn't work in Bootstrap 4 (alpha)

Ilyas karim According to Bootstrap 3 documentation, I added the following properties to the navbar: <nav class="navbar no-margin-bottom" data-spy="affix" data-offset-top="90" > ... </nav> Bootstrap 4 does not add classes to pages suffixed with navbar after sc

Affix doesn't work in Bootstrap 4 (alpha)

Ilyas karim According to Bootstrap 3 documentation, I added the following properties to the navbar: <nav class="navbar no-margin-bottom" data-spy="affix" data-offset-top="90" > ... </nav> Bootstrap 4 does not add classes to pages suffixed with navbar after sc

Affix doesn't work in Bootstrap 4 (alpha)

Ilyas karim According to Bootstrap 3 documentation, I added the following properties to the navbar: <nav class="navbar no-margin-bottom" data-spy="affix" data-offset-top="90" > ... </nav> Bootstrap 4 does not add classes to pages suffixed with navbar after sc

Bootstrap affix reset doesn't work

Vasso 123 I am trying to implement an affix in a bootloader. This shouldn't be a problem, but I want to make it responsive. After resizing the page, some elements are hidden at the top of the page, and due to the change in width, I need to reset the affix and

Affix doesn't work in Bootstrap 4 (alpha)

Ilyas karim According to Bootstrap 3 documentation, I added the following properties to the navbar: <nav class="navbar no-margin-bottom" data-spy="affix" data-offset-top="90" > ... </nav> Bootstrap 4 does not add classes to pages suffixed with navbar after sc

Affix doesn't work in Bootstrap 4 (alpha)

Ilyas karim According to Bootstrap 3 documentation, I added the following properties to the navbar: <nav class="navbar no-margin-bottom" data-spy="affix" data-offset-top="90" > ... </nav> Bootstrap 4 does not add classes to pages suffixed with navbar after sc

Affix doesn't work in Bootstrap 4 (alpha)

Ilyas karim According to Bootstrap 3 documentation, I added the following properties to the navbar: <nav class="navbar no-margin-bottom" data-spy="affix" data-offset-top="90" > ... </nav> Bootstrap 4 does not add classes to pages suffixed with navbar after sc

Affix doesn't work in Bootstrap 4 (alpha)

Ilyas karim According to Bootstrap 3 documentation, I added the following properties to the navbar: <nav class="navbar no-margin-bottom" data-spy="affix" data-offset-top="90" > ... </nav> Bootstrap 4 does not add classes to pages suffixed with navbar after sc

Bootstrap affix reset doesn't work

Vasso 123 I am trying to implement an affix in a bootloader. This shouldn't be a problem, but I want to make it responsive. After resizing the page, some elements are hidden at the top of the page, and due to the change in width, I need to reset the affix and

Navigation tab doesn't change with click in bootstrap

Man · ((Peyman Omidi) I've created two tabs for "Fixtures" and "Results", but when I click on the "Results" tab, nothing changes and it remains in the "Fixtures" tab! Here is my code: <section> <div class="container"> <div class="row"> <div

Navigation tab doesn't change with click in bootstrap

Man · ((Peyman Omidi) I've created two tabs for "Fixtures" and "Results", but when I click on the "Results" tab, nothing changes and it remains in the "Fixtures" tab! Here is my code: <section> <div class="container"> <div class="row"> <div

twitter bootstrap 3 setting active tab in js doesn't work

platform Yep, so it's been asked 1000 times, but I've tried the answers and none seem to work for me. Here are my tags: <ul class="nav nav-tabs"> <li><a href="#profile" data-toggle="tab">Profile</a></li> <li><a href="#account" data-toggle="tab">Account

twitter bootstrap 3 setting active tab in js doesn't work

platform Yep, so it's been asked 1000 times, but I've tried the answers and none seem to work for me. Here are my tags: <ul class="nav nav-tabs"> <li><a href="#profile" data-toggle="tab">Profile</a></li> <li><a href="#account" data-toggle="tab">Account

Bootstrap affix doesn't work with data properties in Aurelia

Kevin Vasko This seems to be a very common problem, as there are about 10 posts about Bootstrap affixes not working. Unfortunately none of these solutions seem to work. The documentation states to use the data attribute to simply apply the "data-spy" attribute

Bootstrap affix doesn't work when navigating backwards

Rudy Wenstaden I've used Bootstrap affixes to create a fixed-position div that behaves like the "how to format" and "similar questions" divs that appear when asking new questions in Stackoverflow. When the page is first loaded it works fine, but if I scroll do

reset/change the offset of the bootstrap affix

Lorski How to change the offset of Affix (Twitter Bootstrap 3) to another value? When I try to call the method twice like this, the second method seems to be ignored and has no effect: $('#navbar-main').affix({ offset: 100}); $('#navbar-main').affix({ offset:

reset/change the offset of the bootstrap affix

Lorski How to change the offset of Affix (Twitter Bootstrap 3) to another value? When I try to call the method twice like this, the second method seems to be ignored and has no effect: $('#navbar-main').affix({ offset: 100}); $('#navbar-main').affix({ offset:

reset/change the offset of the bootstrap affix

Lorski How to change the offset of Affix (Twitter Bootstrap 3) to another value? When I try to call the method twice like this, the second method seems to be ignored and has no effect: $('#navbar-main').affix({ offset: 100}); $('#navbar-main').affix({ offset:

Bootstrap tab doesn't change content on multiple clicks

Abhishek Gage I've been trying to implement tabs in one of my pages. code show as below. <div class="row justify-content-between"> <div class="col-lg-3"> <a class="nav-link p-3 mb-2 sidebar-link justify-content-between text-success ml-4" href="#1"

Change active bootstrap tab on button click

Farjad Hasan I want to click another button to change the active bootstrap tab. I try to add id to tab li and write custom jquery code. $('#emailNotify').click(function () { $('#notify').addClass('active').attr('aria-expanded','true'); $('#myacc').remo

Change active Bootstrap 3 tab with jQuery

dirty penguin I am trying to change tabs programmatically using jQuery. I tried to implement the solution given by @MasterAM here . However, the Chrome console shows an errorUncaught TypeError: undefined is not a function Here is my HTML: <div id="click-me-div

How to change active bootstrap tab using javascript

Beamerfan : I'm trying to change the active label, but am failing to use the javascript onclick element correctly. Here is the code: <ul class="nav nav-tabs" style="text-align: left;"> <li class="active"><a href="#first" data-toggle="tab">First</a></li>

Change active bootstrap tab in angular component

Lively Hi I've been stuck on what looks like this simple problem, going back and forth for a while with SO solutions doesn't seem to fit my use case exactly... I have an angular component whose template contains bootstrap nav pills, these is just used as a lab

Change active Bootstrap 3 tab with jQuery

dirty penguin I am trying to change tabs programmatically using jQuery. I tried to implement the solution given by @MasterAM here . However, the Chrome console shows an errorUncaught TypeError: undefined is not a function Here is my HTML: <div id="click-me-div

How to change color of active tab in bootstrap

Kara I want to create a search box with tabs, but the problem is when I press on the tabs, the active tab doesn't show any text because I set the color to white. I want that; when I press tab, the active tab will show blue text and all other tabs will show whi