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

การกำหนดสีด้วยโมเดล HSLA ใน CSS


เพื่อกำหนดสีด้วยโมเดล Hue-Saturation-Lightness (HSL) พร้อมความทึบแสง ให้ใช้เมธอด hsla() ใน CSS

ตัวอย่าง

คุณสามารถลองรันโค้ดต่อไปนี้เพื่อนำฟังก์ชัน hsla() ไปใช้ใน CSS ได้

<!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>