利用 CSS 用色相-饱和度-亮度-Alpha 模型 (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>

更新于:06-Jul-2020

210 次浏览

开启你的职业生涯

完成课程即可获得认证

开始使用

© . All rights reserved.