使用 CSS 中的色相-饱和度-亮度-透明度模型 (HSLA) 定义颜色


要使用不透明度来定义色相-饱和度-亮度 (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>

更新于: 2020 年 7 月 6 日

209 次浏览

启动你的 职业生涯

完成课程获得认证

开始
广告
© . All rights reserved.