【问题标题】:My checkboxlist doesn't align horizontally properly [closed]我的复选框列表没有正确水平对齐[关闭]
【发布时间】:2014-03-28 05:30:11
【问题描述】:

我的复选框列表非常难看。盒子没有正确对齐。看截图。

【问题讨论】:

  • 可以贴出你用过的HTML代码吗?
  • @SpiderCode 添加代码
  • @Jordjmax 增加宽度,确保文本单行显示。

标签: c# webforms checkboxlist


【解决方案1】:

我想提一下,您的复选框列表将坚持 Width="195px"。 因此,我的建议是根据您的设计增加宽度或将其删除,如下所述:

<asp:CheckBoxList runat="server" ID="cblType" 
                        OnSelectedIndexChanged="cblType_OnSelectedIndexChanged" AutoPostBack="True" 
                        RepeatDirection="Horizontal">
    <Items>
        <asp:ListItem Text="IPP Stories" Value="IPP Stories"></asp:ListItem>
        <asp:ListItem Text="OutReach Activities " Value="OutReach Activities"></asp:ListItem>
        <asp:ListItem Text="CCA" Value="CCA"></asp:ListItem>
        <asp:ListItem Text="Community Work" Value="Community Work"></asp:ListItem>
        <asp:ListItem Text="Competition" Value="Competition"></asp:ListItem>
        <asp:ListItem Text="Overseas Experience" Value="Overseas Experience"></asp:ListItem>
        <asp:ListItem Text="FYPJ" Value="FYPJ"></asp:ListItem>
    </Items>
</asp:CheckBoxList>

建议:

如果我遇到这种情况,那么我会通过在 CheckboxList 属性中添加 RepeatColumns="3"RepeatColumns="4" 将其分成两行。

【讨论】:

  • 我更新了我的帖子。 @SpiderCode
  • 你删除了宽度吗?并确保复选框列表的父元素的宽度为 100%
  • 更新了我的帖子。 @SpiderCode
  • 哦,好像是因为字太长了。 @SpiderCode
  • 您的设计对齐有问题。要么更改设计以使其适合它,要么更改列表项的文本,例如将 OutReach 活动更改为 O/r 活动,将社区工作更改为 Comm Work,将海外经验更改为 海外出口
【解决方案2】:

我认为您不需要在这里指定任何宽度,尽量不要,也许它会完成这项工作。如果没有,请发布相关的 css 样式(如果有)...

<asp:CheckBoxList runat="server" ID="cblType" 
                    OnSelectedIndexChanged="cblType_OnSelectedIndexChanged" AutoPostBack="True" 
                    RepeatDirection="Horizontal">

【讨论】:

  • 更新帖子感谢@Leo
猜你喜欢
  • 1970-01-01
  • 2012-06-04
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多