So I have this navbar:
<nav class="navbar navbar-default" style="background: black; margin-bottom: 0;">
And it’s working fine. However when I’m trying to change styles in external CSS file instead of inline:
.navbar-default {
background: black;
margin-bottom: 0;
}
They are not working at all. CSS file is working fine since I checked and bg pictures are changing. I have problem only with navbar and can’t figure it out. According to this: Change navbar color in Twitter Bootstrap 3 I’m doing everything fine. It’s first time I’m having this issue. Working with bootstrap if anyone is wondering 🙂
Any help guys? I dont want to use inline css.
4
Answers
You need to override the Bootstrap classes, Use
!important
to get it workNote: If you use
!important
all other rules used in your CSS cannot override this declaration.Chances are your styles are being overridden as these styles are being set elsewhere. The C in css stands for cascading. See the cascading order section of this page
The easy option is to simply include your stylesheet after the bootstrap one.
Of course you can override this precedence by adding !important to the end of your style rules but this breaks some of the functionality of CSS and can become difficult to maintain.
I think default bootstrap navbar style is applying so try
!important
in front of property value.I have faced same problem and after searching alot i have found that as
navbar-default
is default class of bootstrap and its not overloaded by external css file.You can use!important
property of css that will help you to load external css file when there default class are overloaded.