嘿,我只有一个简单的Card Bootstrap 4组件。
<div class="card">
<div class="card-header">This is my header</div>
<div class="card-block">This is my block</div>
<div class="card-footer">This is my footer</div>
</div>
我要完成的工作是使页眉和页脚的不透明度为1,而块的不透明度为.4。我尝试在背景颜色样式中使用rbga,但没有运气
.card-block { background-color: rgba(245, 245, 245, 0.4); }
最佳答案
您是否尝试过使用 opacity
.special-card {
/* create a custom class so you
do not run into specificity issues
against bootstraps styles
which tends to work better than using !important
(future you will thank you later)*/
background-color: rgba(245, 245, 245, 1);
opacity: .4;
}
<div class="card">
<div class="card-header">This is my header</div>
<div class="card-block special-card">This is my block</div>
<div class="card-footer">This is my footer</div>
</div>
关于css - 如何在Bootstrap 4中更改卡片块的不透明度,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/42430987/