Skip to main content
maryanns50585047
Known Participant
Aug 5, 2021 4:47 PM UTC
Answered

Create new color for Navbar background

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 is closed to new replies. Start a new post to keep the conversation going.
osgood_Correct answer
Legend
Aug 5, 2021 5:04 PM UTC
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.

 

 

4 replies

Nancy OShea
Community Expert
Community Expert
Aug 5, 2021 5:51 PM UTC

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

https://bootswatch.com/

 

Translate
Nancy O'Shea— Product User & Community Expert
maryanns50585047
Known Participant
Aug 5, 2021 6:14 PM UTC

Wow! A whole new world. Thanks a BUNCH!

Translate
osgood_Correct answer
Legend
Aug 5, 2021 5:04 PM UTC
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.

 

 

Translate
maryanns50585047
Known Participant
Aug 5, 2021 6:15 PM UTC

It worked!! How can I thanks you?!

Translate