(编辑:jimmy 日期: 2024/11/1 浏览:2)
效果预览:
css:
复制代码代码如下:
1: <style type="text/css">
2: <!--
3: body{
4: margin:0;
5: padding:0;
6: background-color:#FFFFFF;
7: }
8: .alpha1,.alpha2{
9: width:100%;
10: height:auto;
11: min-height:250px;/* 必需 */
12: _height:250px;/* 必需 */
13: overflow:hidden;
14: background-color:#FF0000;/* 背景色 */
15: }
16: .alpha1{
17: filter:alpha(opacity=20); /* IE 透明度20% */
18: }
19: .alpha2{
20: background-color:#FFFFFF;
21: -moz-opacity:0.8; /* Moz + FF 透明度20%*/
22: opacity: 0.8; /* 支持CSS3的浏览器(FF 1.5也支持)透明度20%*/
23: }
24: .ap2{
25: position:absolute;
26: }
27: -->
28: </style>
html:
复制代码代码如下:
1: <!--S Demo-->
2: <div class="alpha1">
3: <div class="ap2">
4: <p>背景为红色(#FF0000),透明度20%。</p>
5: </div>
6: <!--[if IE]><![if !IE]><![endif]--> <div class="alpha2"></div> <!--[if IE]><![endif]><![endif]-->
7: </div>