利用 filter:alpha(opacity=60)(IE)與 opacity:0.6(標準瀏覽器)實現半透明浮動層,相容 IE6/7、Firefox。
<div id="wrap">
<div id="box">
<a href="https://www.52css.com/" target="_blank">我愛 CSS</a><br/>
<strong>致力於 Web 標準在中國的應用及發展</strong>
</div>
</div>
#wrap {
position: absolute;
width: 600px; height: 380px;
background: url(52css.jpg); /* 底圖襯托透明效果 */
}
#box {
width: 300px; height: 150px;
filter: alpha(opacity=60); /* IE */
opacity: 0.6; /* 標準 */
margin: 100px 0 0 50px;
background: #fff;
border: 1px #000 solid;
padding: 20px;
font: 14px/170% sans-serif;
}

關鍵點:filter 需元素有寬高或觸發 hasLayout;opacity 為標準屬性,現代瀏覽器均支援。兩行並寫即可完美跨瀏覽器。