Computer >> คอมพิวเตอร์ >  >> การเขียนโปรแกรม >> CSS

กำหนดสีโดยใช้โมเดล Red-Green-Blue-Alpha (RGBA) ด้วย CSS


ใช้ฟังก์ชัน 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>