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

จัดสไตล์อินพุตที่ถูกเลือก (checked) ด้วย CSS


Pseudo-class :checked

ใช้ :checked เพื่อจัดสไตล์ checkbox หรือ radio button ที่ถูกเลือก

ตัวอย่าง

<!DOCTYPE html>
<html>
<head>
  <style>
    input:checked {
      height: 20px;
      width: 20px;
    }
  </style>
</head>
<body>
  <p>Fav sports:</p>
  <form action="">
    <input type="checkbox" value="Football">Football<br>
    <input type="checkbox" value="Cricket">Cricket<br>
    <input type="checkbox" checked="checked" value="Tennis"> Tennis<br>
    <input type="checkbox" value="Badminton">Badminton
  </form>
</body>
</html>