CSS :in-range 選擇器的作用


使用 CSS :in-range 選擇器來設定值在指定範圍內的 <input> 元素的樣式。您可以嘗試執行以下程式碼來實現 :in-range 選擇器 −

示例

線上演示

<!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>

更新於: 2020-06-30

98 瀏覽量

開啟你的 職業生涯

完成課程獲得認證

開始
廣告