JSFiddle - React, Tailwind, and code Playground
HTML
<div class="box">
<div class="t1">利用opacity,文字也跟着透明了</div>
<div class="t2">这才是完美的背景透明</div>
</div>
CSS
.box {
background: lightblue;
padding: 10px;
}
.t1, .t2 {
padding: 10px;
margin: 10px;
font-size: 24px;
}
.t1 {
background: #fff;
opacity: 0.2;
filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=20);
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=20)";
}
.t2 {
background: rgba(255, 255, 255, 0.2);
}