我在ASP.Net中有一个CheckBoxList
,我想更改选中的Item
的背景颜色。
我该怎么办?
我想使用CSS来做到这一点。
我的.aspx
页是:
<asp:CheckBoxList ID="chkdisease" runat="server" RepeatColumns="2">
<asp:ListItem> Spontaneous bleeding</asp:ListItem>
<asp:ListItem>chiae (superficial tiny areas of bleeding into the skin resulting in small reddish spots) , Purpura (easy or excessive bruising), Spontaneous bleeding from </asp:ListItem>
<asp:ListItem>Fatigue</asp:ListItem>
<asp:ListItem>Prolonged bleeding cuts,</asp:ListItem>
<asp:ListItem>DVT (deep vein thrombosi</asp:ListItem>
</asp:CheckBoxList>
答案 0 :(得分:0)
Css
代码以更改background-color
。
<style>
.MyClass input[type=checkbox]:checked + label
{
background-color:red;
}
</style>
并将该类应用于您的CheckBoxList
。像下面一样
<asp:CheckBoxList ID="chkdisease" runat="server" RepeatColumns="2" CssClass="MyClass">
<asp:ListItem> Spontaneous bleeding</asp:ListItem>
<asp:ListItem>chiae (superficial tiny areas of bleeding into the skin resulting in
small reddish spots) , Purpura (easy or excessive bruising), Spontaneous bleeding
from </asp:ListItem>
<asp:ListItem>Fatigue</asp:ListItem>
<asp:ListItem>Prolonged bleeding cuts,</asp:ListItem>
<asp:ListItem>DVT (deep vein thrombosi</asp:ListItem>
</asp:CheckBoxList>