Devdit
 

เปลี่ยนสี Radio button CSS ด้วย accent-color

2.2K

เปลี่ยนสี Radio button CSS ด้วย accent-color บทความนี้สอนใช้คำสั่ง หรือ property accent-color เพื่อเปลี่ยนสี Radio button หรือ input type radio ของ HTML เป็นสีที่ต้องการ สามารถเขียนโปรแกรมได้ดังนี้

 

ตัวอย่าง เปลี่ยนสี Radio button CSS ด้วย accent-color

<style>
#radio_1 {
  accent-color: red;
}
#radio_2 {
  accent-color: green;
}
#radio_3 {
  accent-color: blue;
}
</style>
<input type="radio" id="radio_1" name="v[]" checked> PHP<br/>
<input type="radio" id="radio_2" name="v[]"> HTML<br/>
<input type="radio" id="radio_3" name="v[]"> Java

คำอธิบาย

เปลี่ยนสี Radio button CSS จากตัวอย่างใช้คำสั่ง accent-color กำหนดให้กับ id radio_1 เป็นสีแดง (red) และ id radio_2 เป็นสีเขียว (green) และ id radio_3 เป็นสีฟ้า (blue) และนำ id ทั้ง 3 ไปใช้งานกับ input type radio ของ HTML

เขียน 2 ปีที่แล้ว
ชอบ
ลิ้งก์
แชร์
Devdit มีช่อง YouTube แล้ว
เราสร้างวิดีโอเกี่ยวกับเทคโนโลยี ทำตามง่ายๆ