Is it possible to set the opacity of a background image without affecting the opacity of child elements?
All links in the footer require custom bullets (background image), and the custom bullets should have an opacity of 50%.
<div id="footer"> <ul> <li><a href="#">Link 1</a></li> <li><a href="#">Link 2</a></li> <li><a href="#">Link 3</a></li> <li><a href="#">Link 4</a></li> <li><a href="#">Link 5</a></li> </ul> </div>
#footer ul li { background: url(/images/arrow.png) no-repeat 0 50%; }
I tried setting the list item's opacity to 50%, but the link text's opacity is also 50% - and there doesn't seem to be a way to reset the opacity of the child elements:
#footer ul li { background: url(/images/arrow.png) no-repeat 0 50%; /* will also set the opacity of the link text */ opacity: 0.5; }
I also tried using rgba, but that didn't have any effect on the background image:
#footer ul li { /* rgba doesn't apply to the background image */ background: rgba(255, 255, 255, 0.5) url(/images/arrow.png) no-repeat 0 50%; }
You can combine CSS
linear-gradient()
withrgba()
.