Can I set background image and opacity in the same property?

后端 未结 14 2144
南笙
南笙 2020-11-22 07:58

I can see in CSS references how to set image transparency and how to set a background image. But how can I combine these two in order to set a transparent background image?<

14条回答
  •  误落风尘
    2020-11-22 08:30

    I just added position=absolute,top=0,width=100% in the #main and set the opacity value to the #background

    #main{height:100%;position:absolute; top:0;width:100%}
    #background{//same height as main;background-image:url(image URL);opacity:0.2}
    

    I applied the background to a div before the main.

提交回复
热议问题