Set opacity of background image without affecting child elements

前端 未结 15 2213
闹比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:16

    You can put the image in the div:after or div:before and set the opacity on that "virtual div"

    div:after {
      background: url(https://s3-us-west-2.amazonaws.com/s.cdpn.io/3/owl1.jpg);
      opacity: 0.25;
    }
    

    found here http://css-tricks.com/snippets/css/transparent-background-images/

提交回复
热议问题