样式使用 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.