我正在尝试使输入后的文本加粗,如果输入被选中,但我失败了。我想我没有找到文本。我很感激任何帮助或暗示。
null
input[type="radio"]:checked+ {
font-weight: bold;
}
<label for="radio-foobar">
<input type="radio" id="radio-3" value="3" />
Hello world!
</label>
null
focus-within
和一个转换黑客可以近似于此。过渡是为了确保即使您单击外部,样式也被保留。
null
label {
font-weight: 400;
transition:0s 999s;
}
label:focus-within {
font-weight: 900;
transition:0s;
}
<label for="radio-3">
<input type="radio" id="radio-3" value="3" >
Hello world!
</label>
在html中,需要将Hello World!
覆盖到html标记中,如,而在CSS中,您可以使用
+
CSS选择器选择checked
输入旁边的span。
null
input[type="radio"]:checked + span {
font-weight: bold;
}
<label for="radio-foobar">
<input type="radio" id="radio-3" value="3" />
<span>Hello world!</span>
</label>