RGBA 颜色值是 RGB 颜色值的扩展,带有 alpha 通道 - 该通道规定颜色的不透明度。
实例代码:
<!doctype html>
<html>
<head>
<meta charset=utf-8>
<style>
p{
width:400px;
height:20px;
padding:10px;
}
.red{background-color:rgba(255,0,0,0.3);}
.green{background-color:rgba(0,255,0,0.3);}
.blue{background-color:rgba(0,0,255,0.3);}
.grey{background-color:rgba(192,192,192,0.3);}
.yellow{background-color:rgba(255,255,0,0.3);}
.cerise{background-color:rgba(255,0,255,0.3);}
</style>
</head>
<body>
<h3>用RGBA值定义颜色</h3>
<p class="red">Red</p>
<p class="green">Green</p>
<p class="blue">Blue</p>
<p class="grey">Grey</p>
<p class="yellow">Yellow</p>
<p class="cerise">Cerise</p>
</body>
</html>
运行效果:
![css-252](/sites/default/files/inline-images/css%EF%BC%8D252.png)
评论