【问题标题】:CSS3 Opacity - background only [duplicate]CSS3不透明度-仅背景[重复]
【发布时间】:2013-11-30 21:56:04
【问题描述】:

我想更改导航背景颜色的不透明度,但它也更改了导航链接的不透明度。如何仅更改导航背景颜色的不透明度?

这是我的导航风格:

#navigation { 
    height: 60px;
    width: auto;
    margin: 0 0 20px 0;
    background-color: black;
    border-radius: 8px;
    opacity: 0.7;
}

#navigation ul {
    list-style-type: none;
}

#navigation li {
    padding-left: 22px;
    float: left;
}

#navigation a {
    text-decoration: none;
    display: inline-block;
    float: left;
    padding: 10px 20px 10px 20px;
    color: white;
    margin-top: 10px;
    opacity: 1;
}

#navigation a:hover {
    background-color: orange;
    border-radius: 10px;
}

【问题讨论】:

    标签: html css


    【解决方案1】:

    你可以这样做:

    background-color: rgba(0,0,0,0.7);
    

    这会将黑色不透明度的背景颜色更改为 0.7,而不影响其他任何内容

    【讨论】:

    • 请注意 IE
    【解决方案2】:

    通过使用这种颜色:

    background-color: rgba (0, 0, 0, .5); // black 
    

    这样的话,就会是真实颜色的50%!

    它过滤 alpha 对象并为您提供具有透明效果的真实颜色部分。

    【讨论】:

    • 谢谢!如何仅更改背景图像的不透明度?
    • 为什么不在图形程序中添加透明度? :)
    • @MarkusI。也许不透明度需要程序化?
    猜你喜欢
    • 2011-11-10
    • 2012-05-12
    • 2023-03-16
    • 1970-01-01
    • 2011-10-24
    • 1970-01-01
    • 2018-04-13
    • 2013-07-05
    相关资源
    最近更新 更多