文章出處
文章列表
在 FF/Chrome 等較新的瀏覽器中可以使用css屬性background-color的rgba輕松實現背景透明,而文字保持不透明。而IE6/7/8瀏覽器不支持 rgba,只有使用IE的專屬濾鏡filter:Alpha來實現,但是這樣寫法會把文字也變為透明,因此只有在透明容器的子節點(文本節點除外)內設置 position:relative才能不繼承其父元素的透明濾鏡,代碼如下:
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 2 <html xmlns="http://www.w3.org/1999/xhtml"> 3 <head> 4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 5 <title>Web開發者網絡 - www.admin10000.com</title> 6 <style type="text/css"> 7 .warp{ background:#eee url(back.jpg) no-repeat left top; width:440px;height:400px; border:1px solid #ccc;} 8 .content { width:180px; height:260px; margin:0px auto; padding:30px 30px;background:rgba(255, 255, 255, 0.6)!important; 9 filter:Alpha(opacity=60); background:#fff; /* 使用IE專屬濾鏡實現IE背景透明*/ } 10 .content p{ position:relative;} /*實現IE文字不透明*/ 11 </style> 12 </head> 13 <body> 14 <div class="warp"> 15 <div class="content"><p>Admin10000.com 是WEB開發者學習交流必備網站。Admin10000.com 是WEB開發者學習交流必備網站。Admin10000.com 是WEB開發者學習交流必備網站。Admin10000.com 是WEB開發者學習交流必備網站。Admin10000.com 是WEB開發者學習交流必備網站。Admin10000.com 是WEB開發者學習交流必備網站。</p></div> 16 </div> 17 </body> 18 </html>
以上代碼在IE6.0+/FF3.0+/Opera10+/Chrome/Safari 均測試通過
文章列表
全站熱搜