[英]Change color of selected option in a quiz
I'm new at html/css and I'm having some problems with my code for a quiz.我是 html/css 新手,我的测验代码有一些问题。 I hid radio buttons and now I'm trying to change the color/weight of quiz options when selected (I've tried with active, checked, selected) but nothing seems to work.
我隐藏了单选按钮,现在我试图在选中时更改测验选项的颜色/权重(我尝试过使用活动、选中、选中),但似乎没有任何效果。 The quiz has been created with a Wordpress plugin so i can't change html code (i'm recalling elements in css finding them in the page inspector :/ ) This is the code i used
该测验是使用 Wordpress 插件创建的,因此我无法更改 html 代码(我正在回忆 css 中的元素,在页面检查器中找到它们:/)这是我使用的代码
CSS CSS
label[for=question1_1]:active, label[for=question1_2]:active, label[for=question1_3]:active, label[for=question1_4]:active { color:#ED407B; font-weight:600; }
Here the link of the website https://tinter.altervista.org/test/这里是网站的链接https://tinter.altervista.org/test/
Thanks in advance for help预先感谢您的帮助
Instead of applying the CSS to the label
s themselves, try applying the CSS to the <font>
tags just below them in the HTML.不要将 CSS 应用于
label
本身,而是尝试将 CSS 应用于 HTML 中它们正下方的<font>
标签。 So, in your case, try this instead:所以,在你的情况下,试试这个:
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;
}
As far as I can see, it is the font
tag directly below each label
that you need to apply the CSS to.据我所知,您需要将 CSS 应用到每个
label
下方的font
标签。
If the above doesn't work, try this instead:如果上述方法不起作用,请尝试以下方法:
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;
}
The reason why it does not work:不工作的原因:
You should add :checked
to input tag, since it only works for radio , checkbox and option (select) element that is checked or toggled to an on state.您应该将
:checked
添加到input标签,因为它仅适用于选中或切换到开启状态的单选、复选框和选项(选择)元素。 Refer to this documentation .请参阅此文档。
Assuming label element is placed right after input[type="radio"] element, you can use this:假设标签元件被输入后立即放置[类型=“无线电”]元素,可以使用这样的:
input[type="radio"]:checked + label {
color:#ED407B;
font-weight:600;
}
Let me know if this works for you :)让我知道这是否适合您:)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.