1.4 特殊状态选择器
:link 和 :visited
a:link {
color: black;
}
a:visited {
color: blue;
}
<a href="index.html">点击试试</a>
:hover
p:hover {
font-size: 24px;
}
<p>hover</p>
:activr
button:active {
background-color: yellow;
}
<button>active</button>
:focus
input:focus {
border: 10px solid red;
}
<input>
:enabled 和 :disabled
input:enabled {
border: 1px solid orange;
}
input:disabled {
background-color: lightcyan;
}
<input value="可用">
<input disabled value="不可用">
:checked
input:checked {
width: 40px;
height: 40px;
background-color: orange;
}
<div style="background-color: antiquewhite">
<input type="checkbox">男
</div>
:in-range 和 :out-of-range
input:out-of-range {
border:2px solid red;
}
input:in-range {
border:2px solid yellow;
}
<input type="number" min="4" max="10">
:read-only 和 :read-write
input:read-only {
background-color: lightgray;
}
input:read-write {
background-color: white;
}
<input readonly value="read only">
<input value="read write">
:optional 和 :required
input:optional {
border: 2px solid orange;
}
input:required {
border: 2px dashed red;
}
<input required value="required">
<input value="optional">
:valid 和 :invalid
input:valid {
background-color: greenyellow;
}
input:invalid {
background-color: red;
}
<input type="email" required>