如何在ASP.NET中更改禁用复选框的标签颜色?

时间:2013-04-01 10:39:40

标签: asp.net css checkbox controls

如何通过CSS更改asp控件的禁用复选框标签。检查已禁用但标签颜色没有变化,即使我尝试通过CSS,所以任何线索或提示与CSS?

3 个答案:

答案 0 :(得分:1)

使用加号(+)来获取相邻元素(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;
}

答案 1 :(得分:0)

尝试以下方式

<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;
}

请参阅此checked design

更多讨论

How to change color of checkbox label while toggling checked/unchecked state on click

Change label when checkbox is checked

答案 2 :(得分:0)

你可以这样使用

ListItem li = new ListItem("Richard Byrd", "11");
li.Selected = false;
li.Attributes.Add("Style", "color: red;");
CheckBoxList1.Items.Add(li);

或者你可以这样使用,因为标签在td中呈现,所以下面可以是一个解决方案

的style.css

.chkboxlist td 
{
    color:red;
}

Page.aspx

<asp:CheckBoxList ID="chkboxlist1" runat="server" CssClass="chkboxlist" />
相关问题