:checked

: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;
}

执行结果

Male
Female
I have a bike
I have a car

参考

相关页面

外部链接