asp:CheckBoxList的对齐和填充 [英] Alignment and padding for asp:CheckBoxList

查看:509
本文介绍了asp:CheckBoxList的对齐和填充的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个asp.net复选框列表如下:

I have an asp.net checkboxlist as follows:

    <asp:CheckBoxList ID="CheckBoxList_Genres" runat="server" RepeatColumns="3">
        <asp:ListItem Selected="True">Action</asp:ListItem>
        <asp:ListItem Selected="True">Comedy</asp:ListItem>
        <asp:ListItem Selected="True">Classics</asp:ListItem>
        <asp:ListItem Selected="True">Documentary</asp:ListItem>

[...]

有两个问题:文本不与每个复选框对齐,在一些浏览器(尤其是Safari)中,复选框和文本之间没有填充(文本在复选框旁边)。我知道这里发布的答案:
如何对齐复选框及其标签一致的跨浏览器

I have two problems: the text does not align with each checkbox, and in some browsers (notably Safari), there is no padding between the checkbox and the text (the text rides up against the checkbox). I am aware of the answer posted here: How to align checkboxes and their labels consistently cross-browsers

但是,我无法在asp:checkboxlist上下文中实现这些样式;我知道一个css样式可以为checkboxlist设置,但不要以为这允许我为标签和复选框设置单独的样式。

However, I can't work out how to implement these styles in the asp:checkboxlist context; I know that a css style can be set for the checkboxlist, but do not think that this allows me to set separate styles for the "label" and the "checkbox". Help would be appreciated.

推荐答案

您应该能够将相同的方法应用到CheckBoxList控件的CssClass属性一个常规的复选框。

You should be able to apply the same methods to the CssClass property of your CheckBoxList control as you would a regular checkbox.

这里是一些CSS代码我用来缩进ASP.net复选框列表旁边的长文本:

Here is some CSS code I used to indent long text next to an ASP.net check box list:

.chkChoice input 
{ 
    margin-left: -20px; 
}
.chkChoice td 
{ 
    padding-left: 20px; 
}

ASP.net:

<asp:CheckBoxList id="ChkWork" runat="server" TabIndex="2" CssClass="chkChoice">

这篇关于asp:CheckBoxList的对齐和填充的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆