使用 CSS 的红-绿-蓝-Alpha 模型 (RGBA) 定义颜色
cssweb developmentfront end technology更新于 2025/7/4 20:28:17
使用 CSS rgb() 函数通过 RGB 模型定义颜色。
使用 CSS rgba() 函数设置具有不透明度的 RGB 颜色。
示例
您可以尝试运行以下代码,使用 rgba() 函数设置颜色
<!DOCTYPE html>
<html>
<head>
<style>
h1 {
background-color:hsl(0,100%,50%);
}
h2 {
background-color:rgb(0,0,255);
color: rgb(255,255,255);
}
p {
background-color:rgba(255,0,0,0.9);
}
</style>
</head>
<body>
<h1>Red Background</h1>
<h2>Blue Background</h2>
<p>This is demo text!</p>
</body>
</html>
相关文章
有用资源
css 参考教程 - 该教程包含有关 css 的更多信息:https://www.cainiaomax.com/css/

