Skip to content Skip to sidebar Skip to footer

Overriding Bootstrap Navbar Classes - Wont Work

Alright, so I am having issues overriding some of bootstraps navbar classes. I'm not sure but it works if I use !important but I'd rather avoid that at any cost. So here is my html

Solution 1:

EDIT:

This approach is dealing with overwriting specificity issue, as you are overwriting the style provided in _reboot.scss(which is part of bootstrap)

enter image description here

Hence, this is one of solution to achieve, what you are trying to achieve, your solution must be another way of dealing with this problem.

Example which changes those li without href

.navbar .navbar-nav a:not([href]) {
  color: red;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-beta.2/css/bootstrap.css"  />
<nav class="navbar navbar-default" role="navigation">
  <ul class="navbar navbar-nav">
    <li><a>Actions</a></li>
    <li><a>Profile</a></li>
    <li><a>Kingdom</a></li>
    <li><a href="#">Inventory</a></li>
    <li><a>Alliance</a></li>
    <li><a>Mail Box</a></li>
    <li><a href="user/logout">Logout</a></li>
  </ul>
</nav>

In the below example if you use .navbar .navbar-nav a, it will just change those a with are having href.

.navbar .navbar-nav a {
  color: red;
}

.navbar .navbar-nav a {
  color: red;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-beta.2/css/bootstrap.css"  />
<nav class="navbar navbar-default" role="navigation">
  <ul class="navbar navbar-nav">
    <li><a>Actions</a></li>
    <li><a>Profile</a></li>
    <li><a>Kingdom</a></li>
    <li><a href="#">Inventory</a></li>
    <li><a>Alliance</a></li>
    <li><a>Mail Box</a></li>
    <li><b><a href="user/logout">Logout</a></b></li>
  </ul>
</nav>

Post a Comment for "Overriding Bootstrap Navbar Classes - Wont Work"