Bootstrap CSS isn't being overridden by Custom css

isignisign

So I'm using bootstrap to make a navbar and used their example navbar as my foundation. I fiddled with the bootstrap file to make it so that the navbar will collapse at 995px instead of 768px. Now because of that my navbar's button stays at the left side until the window size is below 768px. I found that if I changed

@media (min-width: 768px) {
    .navbar-header {
        float: left;
    }
}

to

@media (min-width: 995px) {
    .navbar-header {
        float: left;
    }
}

then it works fine.

However I put

@media (min-width: 995px) {
    .navbar-header {
        float: left;
    }
}

into a custom.css and loaded it after bootstrap.css and no change occurred. My custom.css didn't override the boostrap.css. I would like to refrain from changing the bootstrap.css.

This is what the navbar looks like right now enter image description here

This is what it should look like enter image description here

GoldenBeet

So the quick fix is adding !important to your custom styles.

Another way to fix this is to make your custom styles more specific. I'm talking about the selector. You should give the element an Id and call that in your custom styles.

This makes your custom styles more specific, and therefore take precedence. You can also increase the specificity by indicating the parents in the selector.

header #yourNewId { ... } > #yourNewId{ ... } > .navbar-header{ ... }

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

custom css being overridden by bootstrap css

From Dev

I can't understand why my bootstrap custom CSS is being overridden

From Dev

CSS rule not being overridden

From Dev

Bootstrap CSS is not getting overridden?

From Dev

Why isn't this nested css style being applied?

From Dev

My CSS file in Github isn't being used by the HTML file

From Dev

CSS isn't working?

From Dev

Custom CSS won't override default bootstrap css

From Dev

Custom CSS for Bootstrap not working

From Dev

CSS menu isn't centered

From Dev

CSS isn't formatting ActionLinks

From Dev

jQuery isn't modifying CSS

From Dev

Why isn't my css being applied to my checkbox when checked, but only when rendered by razor?

From Dev

Custom MessageListener to DefaultMessageListenerContainer being overridden

From Dev

Custom Link Color Is Being Overridden

From Dev

Custom Bootstrap carousel with thumbnails isn't working

From Dev

Custom Bootstrap carousel with thumbnails isn't working

From Dev

I can't edit my custom.css in a bootstrap project

From Dev

Css class is overridden by jQuery

From Dev

Using custom PHP module, why isn't $_POST being populated?

From Dev

Using Bootstrap CSS along with Custom CSS

From Dev

How to use custom css with bootstrap css

From Dev

Using Bootstrap CSS along with Custom CSS

From Dev

custom css cannot override bootstrap css

From Dev

Creating a custom checkbox with CSS & Bootstrap

From Dev

Custom CSS breaks bootstrap modal

From Dev

CSS :first-of-type isn't working

From Dev

JavaFX CSS URL isn't loading

From Dev

Why isn't my css getting minified?