RGBA是一种颜色表示方法,其中R、G、B分别代表红、绿、蓝三个颜色通道,A代表透明度

RGBA是一种颜色表示方法,其中R、G、B分别代表红、绿、蓝三个颜色通道,A代表透明度。在HTML5中,可以使用CSS的rgba()函数来实现RGBA半透明效果。

例如,下面的代码将创建一个红色的半透明矩形:

<!DOCTYPE html>
<html>
<head>
<style>
.rectangle {
  width: 200px;
  height: 100px;
  background-color: rgba(255, 0, 0, 0.5);
}
</style>
</head>
<body>

<div class="rectangle"></div>

</body>
</html>

在这个例子中,rgba(255, 0, 0, 0.5)表示红色(R=255,G=0,B=0)和50%的透明度(A=0.5)。

  • CSS 中的颜色有三种定义方式:使用颜色方法(RGB、RGBA、HSL、HSLA),十六进制颜色值和预定义的颜色名称。
  • RGBA 是代表Red(红色) Green(绿色) Blue(蓝色)和 Alpha(不透明度)三个单词的缩写。RGBA 颜色值是 RGB
    颜色值的扩展,带有一个 alpha 通道 - 它规定了对象的不透明度。
  • 基本语法:
      R:红色值。正整数 (0~255)
      G:绿色值。正整数 (0~255)
      B:蓝色值。正整数(0~255)
      A:透明度。取值0~1之间
  • 浏览器的兼容性:
    RGBA 颜色值得到以下浏览器的支持:IE9+、Firefox 3+、Chrome、Safari 以及 Opera 10+。
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>RGBA半透明效果</title>
<style type="text/css">
ul {
	list-style:none;
	margin:10px;
	padding:0;
	background:url(../images/charactor.png) 10px 0 no-repeat;
}
li {height:20px;}
li:nth-child(1) {background:rgba(255, 153, 0, 0.1);}
li:nth-child(2) {background:rgba(255, 153, 0, 0.2);}
li:nth-child(3) {background:rgba(255, 153, 0, 0.3);}
li:nth-child(4) {background:rgba(255, 153, 0, 0.4);}
li:nth-child(5) {background:rgba(255, 153, 0, 0.5);}
li:nth-child(6) {background:rgba(255, 153, 0, 0.6);}
li:nth-child(7) {background:rgba(255, 153, 0, 0.7);}
li:nth-child(8) {background:rgba(255, 153, 0, 0.8);}
li:nth-child(9) {background:rgba(255, 153, 0, 0.9);}
li:nth-child(10) {background:rgba(255, 153, 0, 1);}
</style>
<body>
<ul>
  <li></li><li></li><li></li><li></li><li></li>
  <li></li><li></li><li></li><li></li><li></li>
</ul>
</body>
</html>

在这里插入图片描述

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Bol5261

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值