为输入类型复选框添加单独的CSS



我有一个ASP.NET checkboxlist,上面有" chkboxlistnames"作为类:

<asp:CheckBoxList ID ="chkName" runat="server"  RepeatDirection="Horizontal" CssClass="chkboxlistnames" >
<asp:ListItem Text="" Value=""  ></asp:ListItem>
</asp:CheckBoxList>

我使用JQuery,Ajax和JSON方法填充此复选框。在渲染html之后,以这样的方式显示:

<table id="MainContent_chkName" class="chkboxlistnames">
<tbody>
<tr>
<td>
<input id="MainContent_chkName_0" name="UserID" value="2009" type="checkbox">
<label for="MainContent_chkName_0">lekshmi@actsinfo.biz,Lekshmi</label>
</td>
</tr>
</tbody>
</table>

CSS:

input[type="checkbox"]:not(old) + label {
    display: inline-block;
    margin-left: -8px;
    background: url('../img/checks.png') no-repeat 197px 1px;
    line-height: 24px;
    width: 222px;
    text-align: left;
}
label {
    display: inline-block;
    max-width: 100%;
    margin-bottom: 5px;
    font-weight: 700;
}

此样式用于此应用程序中的所有复选框,但是我希望使用ChkboxlistNames的Checkbox单独使用此复选框的CSS,该如何做?

chkboxlistnames在父元素中,因此应该像这样:

.chkboxlistnames input[type="checkbox"] {
    //Your CSS goes here
}

第一个方法,

.chkboxlistnames input[type="checkbox"] {
   //css here
}

第二种方法,

#MainContent_chkName_0{
   //css here
}

最新更新