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

บทบาทของ CSS :in-range Selector

ใช้ :in-range เพื่อจัดสไตล์ <input type="number"> ที่มีค่าอยู่ในช่วงที่กำหนด (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>The style only works for the value entered i.e. 9</p>
</body>
</html>

เงื่อนไข: ต้องมี Attribute min และ max แล้วค่า Value ต้องอยู่ในช่วงนั้น