使用色相-饱和度-亮度-Alpha 模型 (HSLA) 在 CSS 中定义颜色
cssweb developmentfront end technology更新于 2025/7/14 7:40:17
要使用色相-饱和度-亮度模型 (HSL) 和不透明度来定义颜色,请使用 hsla() CSS 方法。
示例
您可以尝试运行以下代码,在 CSS 中实现 hsla() 函数
<!DOCTYPE html>
<html>
<head>
<style>
h1 {
background-color:hsl(0,100%,50%);
}
h2 {
background-color:hsl(192,89%,48%);
}
p {
background-color:hsla(290,100%,50%,0.3);
}
</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/

