我有一个问题......我有这样的标题类
.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/
答案 0 :(得分:12)
如果它仅用于部分透明的背景,您可以使用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/