Background image transparency with CSS3?

后端 未结 8 2247
生来不讨喜
生来不讨喜 2020-12-29 06:41

Is there a way to add transparency to a background-image using CSS3?

8条回答
  •  粉色の甜心
    2020-12-29 07:24

    Background Image Transparency is not part of the CSS Specification (though it should be, please someone put it in, I think Chrome may actually support this though).

    However a partial way to mimic transparency, with a background image, is to include a linear-gradient in the CSS. It will be placed on top of the background image and if you use the background color of the body, you can create the effect of the image fading into the background of the webpage, But you need to use the RGBA color mode and transition from the same color to the same color with different alpha settings like so:

    background:linear-gradient(to right, rgba(0,0,255,0), rgba(0,0,255,1)), url(images/myImage.jpg) fixed no-repeat top center;
    

提交回复
热议问题