Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS Opacity on DIV but not inside content… Reply To: Opacity on DIV but not inside content…

#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;
}