4 、:checked 选择器
:checked 选择器 匹配每个选中的输入元素(仅适用于单选按钮或复选框)
代码如下:
<title>:checked 选择器</title> <style> /* :checked 选择器 匹配每个选中的输入元素(**仅适用于单选按钮或复选框**) */ /* 为 当前这个容器中 选中的 元素 设置如下样式规则 */ .login input:checked{ width: 60px; height: 50px; } </style> </head> <body> <div class="login"> <div> <label for="">性别:</label> <!-- 加入sex 可以选择其中一个性别 如不写,则两个同时可以选中--> <input type="radio" name="sex" id="" value="男" checked="checked">男 <input type="radio" name="sex" id="" value="女">女 </div> <div> <label for="">爱好:</