樣式使用 CSS 設定指定範圍內值<input>元素的樣式


要設定指定範圍內值<input>元素的樣式,請使用 CSS :in-range 選擇器。您可以嘗試執行以下程式碼來實現 :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-21

103 瀏覽量

開啟你的 事業

完成課程認證

入門
廣告
© . All rights reserved.