有没有一种跨浏览器兼容的方法来实现这种效果,而无需准备分离的图像?
基本上,文本所在的框架有一个50%不透明度的白色覆盖层.. 我想找到一种解决方案,不需要创建任何其他图像,除了背景之外。但我不知道是否可能!
有没有一种跨浏览器兼容的方法来实现这种效果,而无需准备分离的图像?
基本上,文本所在的框架有一个50%不透明度的白色覆盖层.. 我想找到一种解决方案,不需要创建任何其他图像,除了背景之外。但我不知道是否可能!
尝试使用RGBA,例如:
div { background-color: rgba(255, 255, 255, 0.5); }
像往常一样,这并不能在所有已编写的浏览器中都起作用。
color: #ffffff; /*回退颜色*/ color: rgba(255, 255, 255, 0.5);
- MischkaTheBearIf you can't use rgba
due to browser support, and you don't want to include a semi-transparent white PNG, you will have to create two positioned elements. One for the white box, with opacity, and one for the overlaid text, solid.
body { background: red; }
.box { position: relative; z-index: 1; }
.box .back {
position: absolute; z-index: 1;
top: 0; left: 0; width: 100%; height: 100%;
background: white; opacity: 0.75;
}
.box .text { position: relative; z-index: 2; }
body.browser-ie8 .box .back { filter: alpha(opacity=75); }
<!--[if lt IE 9]><body class="browser-ie8"><![endif]-->
<!--[if gte IE 9]><!--><body><!--<![endif]-->
<div class="box">
<div class="back"></div>
<div class="text">
Lorem ipsum dolor sit amet blah blah boogley woogley oo.
</div>
</div>
</body>