2017-05-04 64 views
0

我有asp.net的CheckBoxList與「chkboxlistnames」作爲類添加單獨的CSS輸入類型複選框

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

填充此複選框,通過使用jQuery Ajax和JSON method.After渲染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">[email protected],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爲此複選框分隔css,如何做到這一點?

+0

變化'輸入[類型= 「checkbox」]:not(old)+ label {'as'input [class =「chkboxlistnames」]:not(old)+ label {' –

+0

@DavidR爲什麼'input [class =「ch kboxlistnames「]'而不只是使用'input.chkboxlistnames'? – godfrzero

+0

@godfrzero首先,第一個更精確;它僅適用於具有一個類名稱的輸入。 –

回答

2

chkboxlistnames是在父元素,所以它應該是這樣的:

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

第一方法中,

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

方法二,

#MainContent_chkName_0{ 
    //css here 
} 
相關問題