本文重点解决css中使用gba和opaciy设置透明度的区别(附图)问题,希望能够帮助到你
1.使用rgba设置背景色的透明
效果如下:
<body> <div id="box"> 你好啊! </div> </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会同时影响字体的透明度
本网刊登的文章均仅代表作者个人观点,并不代表本网立场。文中的论述和观点,敬请读者注意判断。