使用 CSS 定義紅-綠-藍-透明度 (RGBA) 顏色模型中的顏色


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

更新於: 2020年7月4日

173 次瀏覽

開啟你的職業生涯

完成課程獲得認證

開始學習
廣告
© . All rights reserved.