【发布时间】:2020-12-19 02:12:59
【问题描述】:
问题。我希望这里的输入元素在他为空并且不从范围内选择器中获取样式时没有任何样式,就像他是“范围内”一样...
我该怎么做?我需要做的是输入不会在这里得到样式?代码如下:
li {
list-style: none;
margin-bottom: 1em;
}
input {
border: 1px solid black;
}
input:in-range {
background-color: rgba(251, 255, 0, 0.815);
}
input:out-of-range {
background-color: rgba(255, 0, 0, 0.25);
border: 2px solid red;
}
input:in-range + label::after {
content: 'okay.';
}
input:out-of-range + label::after {
content: 'out of range!';
}
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF8">
<title>Practice vsc</title>
<link rel="stylesheet" href="css/style.css">
</head>
<body>
<ul>Values between 1 and 10 are valid.
<li>
<input id="value1" name="value1" type="number" placeholder="1 to 10" min="1" max="10" value="12">
<label for="value1">Your value is </label>
</li>
</ul>
</body>
</html>
【问题讨论】:
-
你会用javascript吗?
-
我对 JS 不太了解,但如果你能给出代码,它会帮助兄弟