Active nav item doesn't switch until you scroll past the anchor target

General Tech Learning Aids/Tools 3 years ago

2.52K 1 0 0 0

User submissions are the sole responsibility of contributors, with TuteeHUB disclaiming liability for accuracy, copyrights, or consequences of use; content is for informational purposes only and not professional advice.

Answers (1)

Post Answer
profilepic.png
manpreet Tuteehub forum best answer Best Answer 3 years ago

 

I am using navbar-fixed-top and when scroll down the page, the active nav item doesn't switch until you scroll past the anchor target.

This is happening because the browser is waiting until the anchor target "hits" the top of the page before changing the active nav item. I want the active nav item to change when the anchor target reaches the bottom of my navbar.

No preference when it comes to format (will accept any solution) and please DO NOT post anything that has to do with padding... all that does is push the webpage down however many pixels... this is not the solution I am looking for.

 

/* BOOTSTRAP 3.x GLOBAL STYLES
-------------------------------------------------- */

body {
  padding-bottom: 40px;
  color: #5a5a5a;
}
/* NAVBAR
-------------------------------------------------- */

/* Special class on .container surrounding .navbar, used for positioning it into place. */

.navbar-wrapper {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
}
.navbar-default {
  background-color: #763f8d;
  border-color: #5e2d73;
}
.navbar-default .navbar-brand {
  color: #ffffff;
}
.navbar-default .navbar-brand:hover,
.navbar-default .navbar-brand:focus {
  color: #ecdbff;
}
.navbar-default .navbar-text {
  color: #ffffff;
}
.navbar-default .navbar-nav > li > a {
  color: #ffffff;
}
.navbar-default .navbar-nav > li > a:hover,
.navbar-default .navbar-nav > li > a:focus {
  color: #ecdbff;
}
.navbar-default .navbar-nav > .active > a,
.navbar-default .navbar-nav > .active > a:hover,
.navbar-default .navbar-nav > .active > a:focus {
  color: #ecdbff;
  background-color: #5e2d73;
}
.navbar-default .navbar-nav > .open > a,
.navbar-default .navbar-nav > .open > a:hover,
.navbar-default .navbar-nav > .open > a:focus {
  color: #ecdbff;
  background-color: #5e2d73;
}
.navbar-default .navbar-toggle {
  border-color: #5e2d73;

                                                
0 views
0 shares

No matter what stage you're at in your education or career, TuteeHUB will help you reach the next level that you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice sessions to improve your knowledge and scores.

Similar Forum