:checked 选择器匹配每个选中的输入元素(仅适用于单选按钮或复选框)。
input:checked { background:#ff0000; }
HTML
<form action=""> <input type="radio" checked="checked" value="male" name="gender" /> Male<br> <input type="radio" value="female" name="gender" /> Female<br> <input type="checkbox" checked="checked" value="Bike" /> I have a bike<br> <input type="checkbox" value="Car" /> I have a car </form>
CSS
input:checked { background:#ff0000; }
执行结果