Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/41.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Css 选中单选按钮的样式标签,包装在标签标签中_Css_Input_Radio Button_Checked - Fatal编程技术网

Css 选中单选按钮的样式标签,包装在标签标签中

Css 选中单选按钮的样式标签,包装在标签标签中,css,input,radio-button,checked,Css,Input,Radio Button,Checked,如果有人能为我指出以下问题的正确方向,我将不胜感激 所以我有这个代码: <label class="option"><input type="radio" name="rectangle" value="3 1/8 inches" checked><span>d</span> 3 1/8 inches</label> D3 1/8英寸 我想要实现的是设置label.option的样式,它应该基于选中的单选按钮状态。仅使用CSS实现的

如果有人能为我指出以下问题的正确方向,我将不胜感激

所以我有这个代码:

<label class="option"><input type="radio" name="rectangle" value="3 1/8 inches" checked><span>d</span> 3 1/8 inches</label>
D3 1/8英寸
我想要实现的是设置label.option的样式,它应该基于选中的单选按钮状态。仅使用CSS实现的最简单方法是什么


谢谢

我相信您正在寻找:选中的选择器

HTML

<input type="radio" name="rectangle" value="3 1/8 inches" checked>
<label for="rectangle" class="option"><span>d</span> 3 1/8 inches</label>
也许是这样

input[type=“radio”]{
显示:无;
}
跨度{
宽度:50px;
高度:50px;
显示:块;
边框:2px实心#f00;
}
输入[type=“radio”]:选中~span{
背景:#f00;
}


d 3 1/8英寸
为什么复选框在标签内?你能编辑html吗?谢谢。非常接近。我用jQuery找到了答案。这让我走上了正确的道路。感谢您的输入。它只在标签跟随输入收音机时起作用。然而,我需要在标签中包装输入。谢谢你的建议,但我是用jQuery解决的
input[type="radio"]:checked + label {
   color:#ff0000;
}