Skip to main content
maryanns50585047
Known Participant
August 5, 2021
Answered

Create new color for Navbar background

  • August 5, 2021
  • 2 replies
  • 1173 views

A simple thing, you would think. I just want to change the navbar color from dark gray to dark blue. I know I cannot edit Bootstrap so started a new CSS file, but am unable to code it so the navbar color changes with all other elements controlled by bootstrap...

 

www.speedindustrialgas.com

This topic has been closed for replies.
Correct answer osgood_
quote

A simple thing, you would think. I just want to change the navbar color from dark gray to dark blue. I know I cannot edit Bootstrap so started a new CSS file, but am unable to code it so the navbar color changes with all other elements controlled by bootstrap...

 

www.speedindustrialgas.com


By @maryanns50585047

 

Currently this is the css selector which sets your navbar background:

 

 

 

.bg-dark {
background-color: #343a40 !important;
}

 

 

 

 

To alter or add css styles when using Bootstrap you need to create a new css stylesheet and link it to the page AFTER the link to the default bootstrap.min.css file. If you do not link your newly created css stylesheet AFTER then the css styles will not take effect

 

Then in your newly attached css stylesheet:

 

Either add the below (and remove the 'bg-dark' class from the navbar)

 

.navbar {
background-color: blue!important; /* or whatever hex value you require */
}

 

OR change the existing selectors color...

 

.bg-dark {
background-color: blue!important; /* or whatever hex value you require */:
}

 

Does any of that make any sense???

 

Whatever you do DO NOT alter the default Bootstrap css file.

 

 

2 replies

Nancy OShea
Community Expert
August 5, 2021

You can change Bootstrap CSS to a Bootswatch Theme.  For Bootstrap 5, there are 26 themes to choose from.

https://bootswatch.com/

 

Nancy O'Shea— Product User & Community Expert
maryanns50585047
Known Participant
August 5, 2021

Wow! A whole new world. Thanks a BUNCH!

osgood_Correct answer
Brainiac
August 5, 2021
quote

A simple thing, you would think. I just want to change the navbar color from dark gray to dark blue. I know I cannot edit Bootstrap so started a new CSS file, but am unable to code it so the navbar color changes with all other elements controlled by bootstrap...

 

www.speedindustrialgas.com


By @maryanns50585047

 

Currently this is the css selector which sets your navbar background:

 

 

 

.bg-dark {
background-color: #343a40 !important;
}

 

 

 

 

To alter or add css styles when using Bootstrap you need to create a new css stylesheet and link it to the page AFTER the link to the default bootstrap.min.css file. If you do not link your newly created css stylesheet AFTER then the css styles will not take effect

 

Then in your newly attached css stylesheet:

 

Either add the below (and remove the 'bg-dark' class from the navbar)

 

.navbar {
background-color: blue!important; /* or whatever hex value you require */
}

 

OR change the existing selectors color...

 

.bg-dark {
background-color: blue!important; /* or whatever hex value you require */:
}

 

Does any of that make any sense???

 

Whatever you do DO NOT alter the default Bootstrap css file.

 

 

maryanns50585047
Known Participant
August 5, 2021

It worked!! How can I thanks you?!