Reputation: 302
How to change disabled checkbox label of asp controls through CSS. Check disabled but the label colour is not changing even i tried through CSS, so any clue or hint with CSS?
Upvotes: 2
Views: 13889
Reputation: 636
Use plus (+) sign to get adjacent element (http://www.w3.org/TR/CSS21/selector.html#adjacent-selectors)
input[type="checkbox"]:checked+label{ font-weight: bold; }
input[type="checkbox"]:disabled+label
{
color:#ccc;
}
Upvotes: 1
Reputation: 38683
Try this below way
<div>
<input type="checkbox" class="check-with-label" />
<label class="label-for-check">My Label</label>
<div>
.check-with-label:Enabled + .label-for-check {
font-weight: bold;
color:red;
}
See this checked design
More discussions
How to change color of checkbox label while toggling checked/unchecked state on click
Change label when checkbox is checked
Upvotes: 0
Reputation: 17614
You can use like this
ListItem li = new ListItem("Richard Byrd", "11");
li.Selected = false;
li.Attributes.Add("Style", "color: red;");
CheckBoxList1.Items.Add(li);
Or you can use like this as label is rendered in td
so the below can be a solution
Style.css
.chkboxlist td
{
color:red;
}
Page.aspx
<asp:CheckBoxList ID="chkboxlist1" runat="server" CssClass="chkboxlist" />
Upvotes: 0