Home › Forums › CSS › Opacity on DIV but not inside content… › Reply To: Opacity on DIV but not inside content…
December 15, 2015 at 12:58 am
#235845
andrewehipp
Participant
There is actually. You don’t put the background on the div, you create a pseudo element that has the background and the opacity you desire.
div {
position: relative;
}
div:before {
content: '';
display: block;
opacity: 0.5;
background: url('image.jpg');
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
}