Set opacity of background image without affecting child elements

前端 未结 15 2174
闹比i
闹比i 2020-11-22 01:39

Is it possible to set the opacity of a background image without affecting the opacity of child elements?

Example

All links in the footer need a custom bull

15条回答
  •  执念已碎
    2020-11-22 02:28

    #footer ul li
         {
           position:relative;
           list-style:none;
         }
        #footer ul li:before
         {
           background-image: url(imagesFolder/bg_demo.png);
           background-repeat:no-repeat;
           content: "";
           top: 5px;
           left: -10px;
           bottom: 0;
           right: 0;
           position: absolute;
           z-index: -1;
           opacity: 0.5;
        }
    

    You can try this code. I think it will be worked. You can visit the demo

提交回复
热议问题