本篇內(nèi)容介紹了“CSS中怎么實現(xiàn)Firefox與IE透明度”的有關知識,在實際案例的操作過程中,不少人都會遇到這樣的困境,接下來就讓小編帶領大家學習一下如何處理這些情況吧!希望大家仔細閱讀,能夠?qū)W有所成!

海陵網(wǎng)站建設公司創(chuàng)新互聯(lián)建站,海陵網(wǎng)站設計制作,有大型網(wǎng)站制作公司豐富經(jīng)驗。已為海陵上千提供企業(yè)網(wǎng)站建設服務。企業(yè)網(wǎng)站搭建\外貿(mào)網(wǎng)站建設要多少錢,請找那個售后服務好的海陵做網(wǎng)站的公司定做!
CSS中實現(xiàn)Firefox與IE透明度(opacity)的不同方法
Dreamweaver提供的透明度樣式只能支持IE,想要在Firefox下實現(xiàn),需要自己手寫。如下:
1.IE6設置透明度
CSS設置
filter:alpha(opacity=50);
javascript設置
IESpanJs.style.filter=“alpha(opacity=50)”;
2.Firefox3.5設置透明度
Firefox3.5支持CSS3,已經(jīng)不對原來的透明度樣式(-moz-opacity)提供支持(網(wǎng)上查的),在本人的Firefox3.5.5上測試后,發(fā)現(xiàn)確實如此,現(xiàn)在的透明度設置為:
CSS設置
opacity:0.5;
javascript設置
FirefoxSpanJs.style.mozOpacity=“0.5″;
3.Firefox3.5以前版本設置透明度
CSS設置
-moz-opacity:0.5;
javascript設置
FirefoxSpanJs.style.mozOpacity=“0.5″;
4.demo代碼
<HTML> <HEAD> <style type=“text/CSS”> .IECSS { display:-moz-inline-box; display:inline-block; width:100; height:100; background-color:red; filter:alpha(opacity=50); } .Firefox35CSS { display:-moz-inline-box; display:inline-block; width:100; height:100; background-color:blue; opacity:0.5; } .FirefoxCSS { display:-moz-inline-box; display:inline-block; width:100; height:100; background-color:yellow; -moz-opacity:0.5; } </style> <script> window.onload = function() { //設置IE var IESpanJs = document.getElementById(“IESpanJs”); IESpanJs.style.display = “inline-block”; //IE支持 IESpanJs.style.width = 100; IESpanJs.style.height = 100; IESpanJs.style.backgroundColor = “red”; IESpanJs.style.filter=“alpha(opacity=50)”; //設置Firefox3.5.* var Firefox35SpanJs = document.getElementById(“Firefox35SpanJs”); try { Firefox35SpanJs.style.display = “-moz-inline-box”; //Firefox支持 } catch (e) { Firefox35SpanJs.style.display = “inline-block”; //支持IE } Firefox35SpanJs.style.width = 100; Firefox35SpanJs.style.height = 100; Firefox35SpanJs.style.backgroundColor = “blue”; Firefox35SpanJs.style.opacity=“0.5″; //設置Firefox var FirefoxSpanJs = document.getElementById(“FirefoxSpanJs”); try { FirefoxSpanJs.style.display = “-moz-inline-box”; //Firefox支持 } catch (e) { FirefoxSpanJs.style.display = “inline-block”; //支持IE } FirefoxSpanJs.style.width = 100; FirefoxSpanJs.style.height = 100; FirefoxSpanJs.style.backgroundColor = “yellow”; FirefoxSpanJs.style.mozOpacity=“0.5″; } </script> </HEAD> <BODY> <span id=“IESpanCSS” class=“IECSS”>IE_CSS</span> <span id=“Firefox35SpanCSS” class=“Firefox35CSS”>Firefox3.5_CSS</span> <span id=“FirefoxSpanCSS” class=“FirefoxCSS”>Firefox_CSS</span> <br> <br> <span id=“IESpanJs”>IE_Js</span> <span id=“Firefox35SpanJs”>Firefox3.5_Js</span> <span id=“FirefoxSpanJs”>Firefox_Js</span> </BODY> </HTML>“CSS中怎么實現(xiàn)Firefox與IE透明度”的內(nèi)容就介紹到這里了,感謝大家的閱讀。如果想了解更多行業(yè)相關的知識可以關注創(chuàng)新互聯(lián)網(wǎng)站,小編將為大家輸出更多高質(zhì)量的實用文章!
網(wǎng)頁題目:CSS中怎么實現(xiàn)Firefox與IE透明度
URL標題:http://chinadenli.net/article14/goeoge.html
成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供、網(wǎng)站設計、標簽優(yōu)化、定制開發(fā)、企業(yè)網(wǎng)站制作、面包屑導航
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)