實現CSS3不透明度完整代碼

來源:互聯網
上載者:User
如何設定透明度?定義opacity屬性,通過設定該屬效能夠使任何元素呈現出半透明效果,opacity屬性的基本文法如下:

<alphavalue>|inherit

取值說明:

1、<alphavalue>|是由浮點數和單位標識符組成的長度值。不可為負值,預設值為1.opacity取值為1時,則元素為完全不透明的;反之,取值為0時,元素是完全透明的,不可見。

2、inherit表示繼承,即繼承父元素的不透明性。

3、針對IE瀏覽器,可以使用它的私人屬性filter來相容:filter:alpha(alpha=value);。

執行個體:設計燈箱廣告背景布

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  <html xmlns="http://www.w3.org/1999/xhtml">  <head>  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />  <title>opacity</title>  <style type="text/css">  body {       margin:0;       padding:0;   }   p { position:absolute; }   .bg {       width:100%;       height:100%;       background:#000;       opacity:0.7;       filter:alpha(opacity=70);   }   .lightbox {       left:50px;       top:50px;   }   </style>  </head>    <body>  <p class="web"><img src="images/web_bg_9.jpg" width="1259" height="630" /></p>  <p class="bg"></p>  <p class="lightbox"><img src="images/web_bg_10.png" width="80%" /></p>  </body>

示範:

相關文章:

CSS設定一個元素半透明

CSS3教程(8):CSS3透明度指南

CSS3中使用RGBa來調節透明度的樣本說明

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 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.