css實現圖片半透明效果

來源:互聯網
上載者:User
代碼:

這個效果在IE和Mozilla瀏覽器上都可以工作,代碼如下<img alt="powerbookg4.jpg" src="archives/images/powerbookg4.jpg" width="250" height="60" style="-moz-opacity:0.5; filter:alpha(opacity=50);cursor:hand;" onmouseover="this.style.MozOpacity=1;
this.filters.alpha.opacity=100" onmouseout="this.style.MozOpacity=0.5;
this.filters.alpha.opacity=50">

在IE中需要通過"filter"來定義透明度"opacity",而在Mozilla中是可以直接解析"opacity",所以如果要使得這個效果在兩種瀏覽器中都得到支援,需要把兩種設定都加進去。針對IE的設定:this.filters.alpha.opacity=50 而針對Mozilla的設定:this.style.MozOpacity=0.5. 大家可以直接用這行代碼給圖片定義,只須修改圖片地址就能實現效果。

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.