How to set opacity to the background color of a div?

This question already has an answer here:

  • CSS opacity only to background color not the text on it? [duplicate] 11 answers

  • CSS 3引入了RGB颜色,您可以将其与图形组合使用,以实现向后兼容的解决方案。


    我认为rgba是最快最简单的!

    background: rgba(225, 225, 225, .8)


    I think this covers just about all of the browsers. I have used it successfully in the past.

    #div {
        filter: alpha(opacity=50); /* internet explorer */
        -khtml-opacity: 0.5;      /* khtml, old safari */
        -moz-opacity: 0.5;       /* mozilla, netscape */
        opacity: 0.5;           /* fx, safari, opera */
    }
    
    链接地址: http://www.djcxy.com/p/89344.html

    上一篇: 设置背景透明度并且不影响文本内部

    下一篇: 如何将不透明度设置为div的背景颜色?