i want to change the background color of a card in bootstrap from the normal color or "bg-primary" to rgba color of my choice.
card {
padding-left: 20px;
padding-right: 20px;
box-shadow: 0 0px 20px 0 rgba(0,0,0,0.2);
background-color: rgba(0,0,0,0.2);
transition: 0.3s;
}
First of all - you used card
instead of .card
selector. If you want to set your own background-color
for .card
you should remove .bg-primary
class and set rules for .card
:
.card {
...
background-color: rgba(0, 0, 0, 0.2);
...
}
Second - in bootrstrap 4 background-color
of .bg-primary
is declared with !important
, so it overrides any other declarations:
.bg-primary {
background-color: #007bff!important;
}
You can either add your own class to .card
:
.bg-custom-1 {
background-color: rgba(0, 0, 0, 0.2);
}
Or you can set your color for .bg-primary
if you still want to use it (make sure that your css goes after bootstrap css):
.bg-primary {
background-color: rgba(0, 0, 0, 0.2)!important;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With