7

我有一个问题......我有这样的标题类

.header{
    background-color:#626262;
    width:250px;
    height:745px;
    opacity:0.4;
    filter:alpha(opacity=40); /* For IE8 and earlier */
}

在这堂课里,我有这些课......

.logo{
    background-color:#626262;
    opacity:1.0;
    filter:alpha(opacity=100); /* For IE8 and earlier */
    color:#FFF;
    font-size:28px;
    padding-top:125px;
    margin-left:20px;
}

.navigation{
    background-color:#626262;
    opacity:1.0;
    filter:alpha(opacity=100); /* For IE8 and earlier */
    color:#FFF;
    margin-left:20px;
    text-align:left;
    margin-bottom: 125px;
}

.navigation ul{
    list-style:none;
    padding-left:0;
    padding-top:35px;
}

.navigation ul li{
    padding-bottom:20px;
    font-size:24px;
}

.navigation li a{
    color:#FFF;
    text-decoration:none;
}

.social{
    width:100%;
    font-size:18px;
    height: 50px;
    line-height: 72px;
    padding-right: 10px;
}

.social ul {
    list-style-type: none;
    margin: 0;
    padding: 0 0 0 8px;
}

.social li {
    float: left;
}

.social ul .facebook a {
    color: #FFFFFF;
    display: block;
    text-decoration: none;
    background-image: url(http://jamessuske.com/karl/images/facebook.png);
    background-position: center right;
    background-repeat: no-repeat;
    padding-right:65px;
}

.social ul .facebook a:hover {
    background-image: url(http://jamessuske.com/karl/images/facebook_hover.png);
}

.social ul .twitter a {
    color: #FFFFFF;
    display: block;
    text-decoration: none;
    background-image: url(http://jamessuske.com/karl/images/twitter.png);
    background-position: center right;
    background-repeat: no-repeat;
    padding-right:70px;
}

.social ul .twitter a:hover {
    background-image: url(http://jamessuske.com/karl/images/twitter_hover.png);
}

.social ul .pinterest a {
    color: #FFFFFF;
    display: block;
    text-decoration: none;
    background-image: url(http://jamessuske.com/karl/images/pinterest.png);
    background-position: center right;
    background-repeat: no-repeat;
    padding-right:70px;
}

.social ul .pinterest a:hover {
    background-image: url(http://jamessuske.com/karl/images/pinterest_hover.png);
}

并且这些图层褪色到 0.4 的不透明度 ....我的问题是如何让这些图层不褪色,不透明度为 0.4?我希望这是有道理的......这方面的一个例子是http://www.yourthirdeye.ca/

4

1 回答 1

13

如果它只是用于部分透明的背景,您可以使用rgba(),如下所示:

.header{
    background-color: #626262;
    background-color: rgba(98, 98, 98, 0.4);
    width:250px;
    height:745px;
}

这在较旧的浏览器(例如 IE8 和更早版本)中不起作用,所以这background-color就是设置两次的原因 - 第一次是后备。

您还可以使用一些 css 技巧 - 但它们有缺点。如果上述解决方案对您有用,我会同意的。

如果没有,这些链接应该可以帮助您入门:

http://css-tricks.com/non-transparent-elements-inside-transparent-elements/

http://www.impressivewebs.com/css-opacity-that-doesnt-affect-child-elements/

于 2012-07-10T21:11:53.580 回答