使用 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.