樣式使用 CSS 調整超出指定範圍的值的元素


使用 CSS :out-of-range 選擇器調整超出指定範圍的值的 <input> 元素的樣式。

示例

可以嘗試執行以下程式碼來實現 :out-of-range 選擇器

實際操作演示

<!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>The style only works for the value entered out of range</p>
   </body>
</html>

更新於: 01-Jul-2020

117 次瀏覽

開啟 職業生涯

完成課程獲得認證

開始
廣告
© . All rights reserved.