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

บทบาทของ CSS :out-of-range Selector


จัดสไตล์อินพุตที่ค่านอกช่วง

ใช้ :out-of-range สำหรับ <input type="number"> ที่มี min/max และค่าที่ป้อนอยู่นอกช่วง

ตัวอย่าง

<!DOCTYPE html>
<html>
<head>
  <style>
    input:out-of-range {
      border: 3px dashed orange;
      background: yellow;
    }
  </style>
</head>
<body>
  <input type="number" min="5" max="10" value="15">
  <p>ค่า 15 อยู่นอกช่วง 5-10 จึงมีสไตล์นี้</p>
</body>
</html>