Warna CSS
- Hal Sebelumnya Komentar CSS
- Hal Berikutnya Warna RGB CSS
Tentukan warna melalui penggunaan nama warna yang ditakrifkan, atau nilai RGB, HEX, HSL, RGBA, HSLA.
Nama warna CSS
Dalam CSS, boleh menggunakan nama warna untuk tentukan warna:
CSS/HTML 支持 140 种标准颜色名。
CSS 背景色
您可以为 HTML 元素设置背景色:
实例
<h1 style="background-color:DodgerBlue;">China</h1> <p style="background-color:Tomato;">China is a great country!</p>
CSS 文本颜色
您可以设置文本的颜色:
China
China is a great country!
China, officially the People's Republic of China, is a country in East Asia.
实例
<h1 style="color:Tomato;">China</h1> <p style="color:DodgerBlue;">China is a great country!</p> <p style="color:MediumSeaGreen;">China, officially the People's Republic of China...</p>
Warna Bentuk CSS
您可以设置边框的颜色:
实例
<h1 style="border:2px solid Tomato;">Hello World</h1> <h1 style="border:2px solid DodgerBlue;">Hello World</h1> <h1 style="border:2px solid Violet;">Hello World</h1>
Nilai Warna CSS
在 CSS 中,还可以使用 RGB 值、HEX 值、HSL 值、RGBA 值或者 HSLA 值来指定颜色:
与颜色名 "Tomato" 等效:
与颜色名 "Tomato" 等效,但是透明度为 50%:
<h1 style="background-color:rgb(255, 99, 71);">...</h1> <h1 style="background-color:#ff6347;">...</h1> <h1 style="background-color:hsl(9, 100%, 64%);">...</h1> <h1 style="background-color:rgba(255, 99, 71, 0.5);">...</h1> <h1 style="background-color:hsla(9, 100%, 64%, 0.5);">...</h1>
Pelajari lebih banyak tentang nilai warna
Dalam bab berikutnya, anda akan belajar tentang RGB、HEX Dan HSL Tinggalkan Lebih Banyak Pengetahuan.
- Hal Sebelumnya Komentar CSS
- Hal Berikutnya Warna RGB CSS