在CSS中設定透明度的倆種方法

來源:互聯網
上載者:User
這次給大家帶來在CSS中設定透明度的倆種方法,在CSS中設定透明度的注意事項有哪些,下面就是實戰案例,一起來看一下。

1.使用rgba設定背景色的透明

效果如下:

<body>    <p id="box">        你好啊!    </p></body>body {    background-color:red;}#box{    width:200px;    height:200px;    margin:100px auto;    text-align:center;    line-height:200px;    color:white;    background-color:rgba(182,255,0,.5);}


2.使用opacity設定背景色的透明

#box{    width:200px;    height:200px;    margin:100px auto;    text-align:center;    line-height:200px;    color:white;    background-color:rgb(182,255,0);    opacity:0.5;}

總結:通過2中效果的比較我們發現opacity會同時影響字型的透明度

相信看了本文案例你已經掌握了方法,更多精彩請關注php中文網其它相關文章!

推薦閱讀:

用CSS3實現彈幕效果

href和src、link和@import有什麼區別

相關文章

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.