2.290539 ETH / 22393.74 USD

Background color

Similar to the contextual text color classes, set the background of an element to any contextual class. Background utilities do not set color, so in some cases
you'll want to use .text-* Color utilities.

Preview
.bg-primary
.bg-secondary
.bg-success
.bg-danger
.bg-warning
.bg-info
.bg-light
.bg-dark
.bg-body
.bg-white
.bg-transparent
Code Example
    <div class="p-3 mb-2 bg-primary text-white">.bg-primary</div>    <div class="p-3 mb-2 bg-secondary text-white">.bg-secondary</div>    <div class="p-3 mb-2 bg-success text-white">.bg-success</div>    <div class="p-3 mb-2 bg-danger text-white">.bg-danger</div>    <div class="p-3 mb-2 bg-warning text-dark">.bg-warning</div>    <div class="p-3 mb-2 bg-info text-dark">.bg-info</div>    <div class="p-3 mb-2 bg-light text-dark">.bg-light</div>    <div class="p-3 mb-2 bg-dark text-white">.bg-dark</div>    <div class="p-3 mb-2 bg-body text-dark">.bg-body</div>    <div class="p-3 mb-2 bg-white text-dark">.bg-white</div>    <div class="p-3 mb-2 bg-transparent text-dark">.bg-transparent</div>
Background gradient

By adding a .bg-gradient class, a linear gradient is added as background image to the backgrounds. This gradient starts with a semi-transparent
white which fades out to the bottom.

.bg-primary.bg-gradient
.bg-secondary.bg-gradient
.bg-success.bg-gradient
.bg-danger.bg-gradient
.bg-warning.bg-gradient
.bg-info.bg-gradient
.bg-light.bg-gradient
.bg-dark.bg-gradient
Code Example
    <div class="p-3 mb-2 bg-primary bg-gradient text-white">.bg-primary</div>    <div class="p-3 mb-2 bg-secondary bg-gradient text-white">.bg-secondary</div>    <div class="p-3 mb-2 bg-success bg-gradient text-white">.bg-success</div>    <div class="p-3 mb-2 bg-danger bg-gradient text-white">.bg-danger</div>    <div class="p-3 mb-2 bg-warning bg-gradient text-dark">.bg-warning</div>    <div class="p-3 mb-2 bg-info bg-gradient text-dark">.bg-info</div>    <div class="p-3 mb-2 bg-light bg-gradient text-dark">.bg-light</div>    <div class="p-3 mb-2 bg-dark bg-gradient text-white">.bg-dark</div>
Opacity

To change that opacity, override --bs-bg-opacity via custom styles or inline styles.

This is default success background
This is 50% opacity success background

Or, choose from any of the .bg-opacity utilities:

This is default success background
This is 75% opacity success background
This is 50% opacity success background
This is 25% opacity success background
This is 10% opacity success background
Code Example
    <!-- --bs-bg-opacity custom inline style -->    <div class="bg-success p-2 text-white">This is default success background</div>    <div class="bg-success p-2" style="--bs-bg-opacity: .5;">This is 50% opacity success background</div>    <!-- .bg-opacity utilities class -->    <div class="bg-success p-2 text-white">This is default success background</div>    <div class="bg-success p-2 text-white bg-opacity-75">This is 75% opacity success background</div>    <div class="bg-success p-2 text-dark bg-opacity-50">This is 50% opacity success background</div>    <div class="bg-success p-2 text-dark bg-opacity-25">This is 25% opacity success background</div>    <div class="bg-success p-2 text-dark bg-opacity-10">This is 10% opacity success background</div>