Overwrite Bootstrap style for a single page

1.3k views Asked by At

I tried overwriting the "margin-bottom: 20px" in .nav by changing the value into "margin-bottom: 0" but it does work. It is only used once for a specific webpage.

I don't know what to do?

I still wanto to keep the original value "margin-bottom: 20px" because it is used in other webpages.

<style>

.nav{
margin-bottom: 20px;
}

</style>

enter image description here

3

There are 3 answers

0
m4n0 On BEST ANSWER

Use inline style which has higher priority and will work since you are using only for a single page.

<div class="nav" style="margin-bottom: 0;">
0
Paulie_D On

You have to make sure that you are:

Firstly

Matching styles, so

<style>

   nav  {
      margin-bottom: 20px;
    }

</style>

needs to be

<style>

   .nav   { /* note the period/full-stop  */
      margin-bottom: 20px;
    }

</style>

Secondly

The <style> declaration needs to come after the Bootstrap CSS is loaded in the <head> of your specific page so it overrides the previous CSS statement.

0
David Wilkinson On

Are you linking to the bootstrap.min.css file before or after your own custom stylesheet / internal page styling?

Also, bootstrap.min.css is targeting the CLASS of nav (.nav). You're targeting the HTML5 element nav.

EDIT: I notice you changed the nav to .nav in your OP.