R、G、B三个参数的正整数取值是0 ~ 255,百分比取值是0% ~ 100%.浏览器支持超出范围的数值将被截至其最接近的取值极限,参数A的取值在0~1之间.需要特别注意的是,并非所有的浏览器都支持百分数参数值.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>rgba设置字体颜色</title>
<style type="text/css">
/*
color属性是css中设置字体颜色
font-size属性设置字体大小
*/
.first{
color:rgba(255,128,0,0.2);
font-size:50px;
}
.second{
color:rgba(90%,70%,50%,0.8);
font-size:50px;
}
.third{
color:rgba(160,255,150,.6);/*0.6也可以写成.6*/
font-size:50px;
}
</style>
</head>
<body>
<div class="first">传智播客</div>
<div class="second">传智播客</div>
<div class="third">传智播客</div>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>rgba设置字体颜色</title>
<style type="text/css">
/*
color属性是css中设置字体颜色
font-size属性设置字体大小
*/
.first{
color:rgba(255,128,0,0.2);
font-size:50px;
}
.second{
color:rgba(90%,70%,50%,0.8);
font-size:50px;
}
.third{
color:rgba(160,255,150,.6);/*0.6也可以写成.6*/
font-size:50px;
}
</style>
</head>
<body>
<div class="first">传智播客</div>
<div class="second">传智播客</div>
<div class="third">传智播客</div>
</body>
</html>
| 欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/) | 黑马程序员IT技术论坛 X3.2 |