CSS :in-range 伪类

:in-range 伪类选择值在指定范围内的所有元素。
它适用于具有或者具有范围限制的元素。
如果没有此限制,则元素不能“在范围内”或者“超出范围”。

:in-range 伪类可以与其他伪类链接(例如,:hover)。

:in-range 选择器仅适用于具有 min 和/或者 max 属性的 <input> 元素。

语法

:in-range {
  css declarations;
}

:in-range 伪类示例:

<!DOCTYPE html>
<html>
  <head>
    <title>Title of the document</title>
    <style>
      input:in-range {
        border: 2px solid #666;
      }
    </style>
  </head>
  <body>
    <h2>:in-range selector example</h2>
    <form>
      <input type="number" min="1" max="10" value="5">
    </form>
  </body>
</html>
日期:2020-06-02 22:14:35 来源:oir作者:oir