css下html中如何根据标签文本内容改变字体颜色

thtygnil  于 2022-12-05  发布在  其他
关注(0)|答案(1)|浏览(194)

因此,我有一个单选按钮,文本“是”和“否”,我希望字体颜色改变,如果任何一个被选中。

  • 是(绿色)
  • 否(红色)

下面是html格式的代码

<asp:RadioButtonList ID="RadioButtonList1" runat="server" RepeatDirection="Horizontal">
  <asp:ListItem Text="No" Value="False" />
  <asp:ListItem Text="Yes" Value="True" />
</asp:RadioButtonList>

我在css中有下面的代码,它改变了选中的单选按钮的标签
input[type="radio"]:checked + label { font-weight: bolder !important; }

x9ybnkn6

x9ybnkn61#

您可以使用方括号定位任何属性,包括“Text”属性:
第一个

相关问题