Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to change card background color in bootstrap

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;
 }
like image 342
yousif fayed Avatar asked Oct 21 '19 05:10

yousif fayed


1 Answers

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;
}
like image 73
fen1x Avatar answered Oct 14 '22 11:10

fen1x