JSFiddle - React, Tailwind, and code Playground
HTML
<div class="opBkg red op10">Red 10%</div>
<div class="opBkg red op50">Red 50%</div>
<div class="opBkg blue op80">Blue 80%</div>
CSS
div {
width: 50px;
height: 50px;
float: left;
}
.opBkg {
position: relative;
}
.opBkg:after {
content: '';
position: absolute;
z-index: -1;
top: 0;
right: 0;
left: 0;
bottom: 0;
}
.red:after {
background-color: red;
}
.blue:after {
background-color: blue;
}
.op10:after {
opacity: .1;
}
.op50:after {
opacity: .5;
}
.op80:after {
opacity: .8;
}