Background image transparency with CSS3?

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

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

8条回答
  •  渐次进展
    2020-12-29 07:25

    You can also accomplish a transarent background image using the css3 pseudo classes and opacity. For example....

    HTML:

    ...content that should have 100% opacity...

    CSS:

    .transparent-background { ... }
    .transparent-background:after {
        background: url("../images/yourimage.jpg") repeat scroll 0 0 transparent;
        opacity: 0.5;
        bottom: 0;
        content: "";
        left: 0;
        position: absolute;
        right: 0;
        top: 0;
        z-index: 0;
    }
    

    See the sample - http://jsfiddle.net/sjLww/

提交回复
热议问题