问题描述
我是 html/css 新手,我的测验代码有一些问题。 我隐藏了单选按钮,现在我试图在选中时更改测验选项的颜色/权重(我尝试过使用活动、选中、选中),但似乎没有任何效果。 该测验是使用 wordpress 插件创建的,因此我无法更改 html 代码(我正在回忆 css 中的元素,在页面检查器中找到它们:/) 这是我使用的代码
CSS
res = [[ 4,40,400,18],[ 4,60,17],18]]
这里是网站的链接 https://tinter.altervista.org/test/
预先感谢您的帮助
解决方法
不要将 CSS 应用于 label
本身,而是尝试将 CSS 应用于 HTML 中它们正下方的 <font>
标签。所以,在你的情况下,试试这个:
label[for=question1_1] > font,label[for=question1_2] > font,label[for=question1_3] > font,label[for=question1_4] > font {
color:#ED407B;
font-weight:600;
}
据我所知,您需要将 CSS 应用到每个 font
正下方的 label
标记。
如果上述方法不起作用,请尝试以下方法:
label[for=question1_1] font,label[for=question1_2] font,label[for=question1_3] font,label[for=question1_4] font {
color:#ED407B;
font-weight:600;
}
,
不起作用的原因:
您应该将 :checked
添加到 input 标签,因为它仅适用于 radio、checkbox 和 option(选择)被选中或切换到开启状态的元素。请参阅此documentation。
假设 label 元素位于 input[type="radio"] 元素之后,您可以使用:
input[type="radio"]:checked + label {
color:#ED407B;
font-weight:600;
}
让我知道这是否适合您:)