自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

CSS中輕松實現(xiàn)Firefox與IE透明度

開發(fā) 前端
本文向大家描述一下CSS中實現(xiàn)Firefox與IE透明度(opacity)的不同方法,Dreamweaver提供的透明度樣式只能支持IE,想要在Firefox下實現(xiàn),需要自己手寫。

你對CSS中實現(xiàn)Firefox與IE透明度的概念是否了解,這里和大家分享幾種實現(xiàn)Firefox與IE透明度的方法,希望對你的學習有所幫助。

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代碼

  1. <HTML>   
  2. <HEAD>   
  3. <style type=“text/CSS”>   
  4. .IECSS {   
  5. display:-moz-inline-box;   
  6. display:inline-block;   
  7. width:100;   
  8. height:100;   
  9. background-color:red;   
  10. filter:alpha(opacity=50);   
  11. }   
  12. .Firefox35CSS {   
  13. display:-moz-inline-box;   
  14. display:inline-block;   
  15. width:100;   
  16. height:100;   
  17. background-color:blue;   
  18. opacity:0.5;   
  19. }   
  20. .FirefoxCSS {   
  21. display:-moz-inline-box;   
  22. display:inline-block;   
  23. width:100;   
  24. height:100;   
  25. background-color:yellow;   
  26. -moz-opacity:0.5;   
  27. }   
  28. </style>   
  29.     
  30. <script>   
  31. window.onload = function() {   
  32. //設置IE   
  33. var IESpanJs = document.getElementById(“IESpanJs”);   
  34. IESpanJs.style.display = “inline-block”;  //IE支持   
  35. IESpanJs.style.width = 100;   
  36. IESpanJs.style.height = 100;   
  37. IESpanJs.style.backgroundColor = “red”;   
  38. IESpanJs.style.filter=“alpha(opacity=50)”;   
  39.     
  40. //設置Firefox3.5.*   
  41. var Firefox35SpanJs = document.getElementById(“Firefox35SpanJs”);   
  42. try   
  43. {   
  44. Firefox35SpanJs.style.display = “-moz-inline-box”; //Firefox支持   
  45. }   
  46. catch (e)   
  47. {   
  48. Firefox35SpanJs.style.display = “inline-block”; //支持IE   
  49. }   
  50.     
  51. Firefox35SpanJs.style.width = 100;   
  52. Firefox35SpanJs.style.height = 100;   
  53. Firefox35SpanJs.style.backgroundColor = “blue”;   
  54. Firefox35SpanJs.style.opacity=“0.5″;   
  55.     
  56. //設置Firefox   
  57. var FirefoxSpanJs = document.getElementById(“FirefoxSpanJs”);   
  58. try   
  59. {   
  60. FirefoxSpanJs.style.display = “-moz-inline-box”; //Firefox支持   
  61. }   
  62. catch (e)   
  63. {   
  64. FirefoxSpanJs.style.display = “inline-block”; //支持IE   
  65. }   
  66.     
  67. FirefoxSpanJs.style.width = 100;   
  68. FirefoxSpanJs.style.height = 100;   
  69. FirefoxSpanJs.style.backgroundColor = “yellow”;   
  70. FirefoxSpanJs.style.mozOpacity=“0.5″;   
  71.     
  72. }   
  73. </script>   
  74.     
  75. </HEAD>   
  76.     
  77. <BODY>   
  78. <span id=“IESpanCSS” class=“IECSS”>IE_CSS</span>   
  79. <span id=“Firefox35SpanCSS” class=“Firefox35CSS”>Firefox3.5_CSS</span>   
  80. <span id=“FirefoxSpanCSS” class=“FirefoxCSS”>Firefox_CSS</span>   
  81. <br>   
  82. <br>   
  83. <span id=“IESpanJs”>IE_Js</span>   
  84. <span id=“Firefox35SpanJs”>Firefox3.5_Js</span>   
  85. <span id=“FirefoxSpanJs”>Firefox_Js</span>   
  86. </BODY>   
  87. </HTML>   
  88.  

  文章來源: Div-CSS.net設計網(wǎng) 參考:http://www.div-CSS.net/div_CSS/topic/index.asp?id=10037

【編輯推薦】

  1. CSS中padding和margin屬性用法說明
  2. 探究IE8與IE7具體功能中窗口功能按鈕的變化
  3. 剖析Margin和Padding屬性中四個值的先后順序及區(qū)別
  4. 九步輕松解決IE6的各種疑難雜癥
  5. 技術前沿 一段JS代碼輕松解決IE6-IE8的兼容性問題
責任編輯:佚名 來源: div-CSS.net
相關推薦

2020-12-01 10:54:41

GIMP圖片透明度

2022-02-15 09:31:43

透明度CSS

2010-09-13 15:32:38

DIV背景

2020-11-27 08:51:29

CSSOpacity透明度

2019-10-10 10:30:07

云計算云安全公共云

2024-01-17 08:22:23

16進制值透明度顏色值

2010-09-01 15:16:47

CSSIEFirefox

2010-08-31 09:24:29

FireFoxIECSS

2009-11-03 17:35:05

VB.NET窗體透明度

2024-08-02 12:05:00

2022-05-16 10:29:17

開源社區(qū)透明度開發(fā)者

2010-08-20 14:47:02

IEFirefoxCSS

2010-08-27 15:56:52

IEFirefoxCSS

2024-03-06 11:43:42

2020-09-17 14:32:52

AI

2010-08-16 15:15:12

CSSFireFoxIE

2024-07-30 09:43:59

2022-06-28 13:51:55

數(shù)據(jù)中心透明度和創(chuàng)新

2022-07-27 10:51:05

數(shù)據(jù)中心

2020-09-18 12:27:44

AIGPT-3算法
點贊
收藏

51CTO技術棧公眾號