主页
CSS
CSS 背景
试用:不透明度和 rgba() 之间的区别
运行 ❯
获取您
自己的
网站
×
更改方向
保存代码
更改主题,深色/浅色
转到空间
<!DOCTYPE html> <html> <head> <style> div { background: rgb(0, 128, 0); } div.first { background: rgba(0, 128, 0, 0.1); } div.second { background: rgba(0, 128, 0, 0.3); } div.third { background: rgba(0, 128, 0, 0.6); } </style> </head> <body> <h1>Transparent Boxes 2</h1> <p>Result with opacity:</p> <div style="opacity:0.1;"> <h1>10% opacity</h1> </div> <div style="opacity:0.3;"> <h1>30% opacity</h1> </div> <div style="opacity:0.6;"> <h1>60% opacity</h1> </div> <div> <h1>opacity 1</h1> </div> <p>Result with rgba():</p> <div class="first"> <h1>10% opacity</h1> </div> <div class="second"> <h1>30% opacity</h1> </div> <div class="third"> <h1>60% opacity</h1> </div> <div> <h1>default</h1> </div> <p>Notice how the text gets transparent as well as the background color when using the opacity property.</p> </body> </html>