开发者

Weird spacing of Checkbox labels

when I try to create a number of Checkboxes, I have strange spaces inserted: image

<td style="width:85开发者_如何学C%;white-space:nowrap;" colspan=3>
    <asp:CheckBox ID="rdoSchool" runat="server" Text="School (NSL)" />
    <asp:CheckBox ID="rdoSFS" runat="server" Text="Summer Food Service" />
    <asp:CheckBox ID="rdoOther" runat="server" Text="Other (Specify)" />&nbsp<asp:TextBox ID="txtOther" Width="125px" runat="server" />
</td>

How can I make the label closer to the checkbox?


This isn't default styling, and is most likely caused by your CSS. Use a tool like Firebug (on Firefox) or Developer Tools on IE8 to find the applied CSS rules (Should be F12 either way).


Take a look at the markup the CheckBox control generates.

... "Now there's your problem" - Adam Savage, Mythbusters.


Basically the CheckBox control (along with the RadioButtonList control) generates crappy markup. One way to fix this, is to extend and override the Render method to implement some sensible markup-generation code. Another option is to force the HTML-tables the control generates into place with some clever CSS tricks.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜