是否可以显示复选框列表分组,如下图所示?我正在使用 asp.net 控件并绑定数据。但我需要制作相同的风格。我怎样才能使用 CSS 做到这一点?
<asp:DataList ID="dl_Groups_1" RepeatColumns="1" runat="server" OnItemDataBound="dl_Groups_1_ItemDataBound" RepeatDirection="vertical" ShowFooter="False" ShowHeader="False">
<ItemTemplate>
<asp:CheckBox Font-Bold="true" runat="server" ID="chk_Group_1" Text='<%# Eval("category_type") %>' Value='<%# Eval("service_type_category_id") %>' onclick="OnGroupClick" />
<asp:CheckBoxList runat="server" ID="chkServiceType_1" Style="padding-left: 20px" DataValueField="ServiceTypeID" DataTextField="Name" EnableViewState="true">
</asp:CheckBoxList>
<br />
</ItemTemplate>
</asp:DataList>
在浏览器中呈现的 HTML:
<table cellspacing="0" border="0" style="border-collapse:collapse;" id="ctl00_cphMain_ctlEsnSearchByServices_dl_Groups_1">
<tbody>
<tr>
<td>
<span style="font-weight:bold;"><input type="checkbox" onclick="selectGroupAll(ctl00_cphMain_ctlEsnSearchByServices_dl_Groups_1_ctl00_chk_Group_1);" name="ctl00$cphMain$ctlEsnSearchByServices$dl_Groups_1$ctl00$chk_Group_1" id="ctl00_cphMain_ctlEsnSearchByServices_dl_Groups_1_ctl00_chk_Group_1"><label for="ctl00_cphMain_ctlEsnSearchByServices_dl_Groups_1_ctl00_chk_Group_1">Stay-In Facilities</label></span>
<table border="0" style="padding-left: 20px" id="ctl00_cphMain_ctlEsnSearchByServices_dl_Groups_1_ctl00_chkServiceType_1">
<tbody>
<tr>
<td><input type="checkbox" name="ctl00$cphMain$ctlEsnSearchByServices$dl_Groups_1$ctl00$chkServiceType_1$0" id="ctl00_cphMain_ctlEsnSearchByServices_dl_Groups_1_ctl00_chkServiceType_1_0"><label for="ctl00_cphMain_ctlEsnSearchByServices_dl_Groups_1_ctl00_chkServiceType_1_0">DEF</label></td>
</tr><tr>
<td><input type="checkbox" name="ctl00$cphMain$ctlEsnSearchByServices$dl_Groups_1$ctl00$chkServiceType_1$1" id="ctl00_cphMain_ctlEsnSearchByServices_dl_Groups_1_ctl00_chkServiceType_1_1"><label for="ctl00_cphMain_ctlEsnSearchByServices_dl_Groups_1_ctl00_chkServiceType_1_1">ABC </label></td>
</tr><tr>
<td><input type="checkbox" name="ctl00$cphMain$ctlEsnSearchByServices$dl_Groups_1$ctl00$chkServiceType_1$2" id="ctl00_cphMain_ctlEsnSearchByServices_dl_Groups_1_ctl00_chkServiceType_1_2"><label for="ctl00_cphMain_ctlEsnSearchByServices_dl_Groups_1_ctl00_chkServiceType_1_2">XYZ</label></td>
</tr>
</tbody>
</table>
<br>
</td>
</tr>
<tr>
<td>
<span style="font-weight:bold;"><input type="checkbox" onclick="selectGroupAll(ctl00_cphMain_ctlEsnSearchByServices_dl_Groups_1_ctl01_chk_Group_1);" name="ctl00$cphMain$ctlEsnSearchByServices$dl_Groups_1$ctl01$chk_Group_1" id="ctl00_cphMain_ctlEsnSearchByServices_dl_Groups_1_ctl01_chk_Group_1"><label for="ctl00_cphMain_ctlEsnSearchByServices_dl_Groups_1_ctl01_chk_Group_1">Other Services</label></span>
<table border="0" style="padding-left: 20px" id="ctl00_cphMain_ctlEsnSearchByServices_dl_Groups_1_ctl01_chkServiceType_1">
<tbody>
<tr>
<td><input type="checkbox" name="ctl00$cphMain$ctlEsnSearchByServices$dl_Groups_1$ctl01$chkServiceType_1$0" id="ctl00_cphMain_ctlEsnSearchByServices_dl_Groups_1_ctl01_chkServiceType_1_0"><label for="ctl00_cphMain_ctlEsnSearchByServices_dl_Groups_1_ctl01_chkServiceType_1_0">GHJ</label></td>
</tr><tr>
<td><input type="checkbox" name="ctl00$cphMain$ctlEsnSearchByServices$dl_Groups_1$ctl01$chkServiceType_1$1" id="ctl00_cphMain_ctlEsnSearchByServices_dl_Groups_1_ctl01_chkServiceType_1_1"><label for="ctl00_cphMain_ctlEsnSearchByServices_dl_Groups_1_ctl01_chkServiceType_1_1">IJK</label></td>
</tr><tr>
<td><input type="checkbox" name="ctl00$cphMain$ctlEsnSearchByServices$dl_Groups_1$ctl01$chkServiceType_1$2" id="ctl00_cphMain_ctlEsnSearchByServices_dl_Groups_1_ctl01_chkServiceType_1_2"><label for="ctl00_cphMain_ctlEsnSearchByServices_dl_Groups_1_ctl01_chkServiceType_1_2">MNO</label></td>
</tr>
</tbody>
</table>
<br>
</td>
</tr>
</tbody>
</table>