【问题标题】:Nontransparent child in transparent parent透明父级中的非透明子级
【发布时间】:2010-06-13 18:31:21
【问题描述】:

我在 html 中有透明的 div 块。其中还有另一个子块。是否可以使该子 div 不透明?

【问题讨论】:

    标签: html transparency


    【解决方案1】:

    我不相信,但你可以这样做:

    <div style="position: relative">
        <div style="position: absolute; top: 0; left: 0; opacity: 0.5; z-index: 2;">
        </div>
        <div style="position: absolute; top: 0; left: 0; z-index: 3;">
            <p>I'm fully opaque</p>
        </div>
    </div>
    

    这种技术基本上将一个 div 覆盖在另一个之上。它对于动画背景图像和其他情况很有用,但可能不适用于您的用例 - 您必须详细说明。

    【讨论】:

      【解决方案2】:

      不,这是不可能的。但如果您只是在寻找透明背景,您可以使用rgba(RRR, GGG, BBB, AAA) 构造设置background-color,其中最后一个数字是alpha 透明度值。但它只适用于现代浏览器。

      【讨论】:

        猜你喜欢
        • 2014-10-27
        • 1970-01-01
        • 1970-01-01
        • 2013-09-02
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2020-09-10
        • 2016-02-15
        相关资源
        最近更新 更多