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

จัดสไตล์อินพุตที่มีค่าอยู่ในช่วงที่กำหนดด้วย CSS


Pseudo-class :in-range

ใช้ :in-range selector เพื่อจัดสไตล์ <input> ที่มีแอตทริบิวต์ min และ max และค่าที่ป้อนอยู่ในช่วงนั้น

ตัวอย่าง

<!DOCTYPE html>
<html>
<head>
  <style>
    input:in-range {
      border: 3px dashed orange;
      background: yellow;
    }
  </style>
</head>
<body>
  <input type="number" min="5" max="10" value="9">
  <p>สไตล์ทำงานเพราะค่า 9 อยู่ในช่วง 5-10</p>
</body>
</html>