【问题标题】:How to center a RadioButtonList in a table cell如何在表格单元格中居中 RadioButtonList
【发布时间】:2015-09-23 22:29:00
【问题描述】:

这应该很容易。如何将单选按钮列表居中?过去并不难。 下面的 HTML 不起作用。我错过了什么?

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <table style="width:100%">
                  <tr>
                      <td  style="text-align: center">
                          <asp:RadioButtonList ID="radUserType" runat="server" 
                              RepeatDirection="Horizontal">
                          </asp:RadioButtonList>
                      </td>
                  </tr>
           </table>
    </div>
    </form>
</body>
</html>

【问题讨论】:

  • 不要在布局中使用表格。使用 CSS。 stackoverflow.com/questions/83073/… 哦,不要使用内联样式。
  • 我使用了一个样式表,但是对于这个例子,我想让它变得非常简单。而且我不相信“不要使用表格”是一个严肃的答案。
  • 当然不是。这就是我将其作为评论发布的原因。
  • 你想让它以你&lt;td&gt;为中心吗?
  • 生成的 HTML 是什么样子的?

标签: html css radiobuttonlist


【解决方案1】:

RepeatLayout="流"

在跨度而不是表格中呈现 RadioButtonList。

【讨论】:

    【解决方案2】:

    尝试使用 td 属性:

    <td align="center"> 
          <asp:RadioButtonList ID="radUserType" runat="server" 
           RepeatDirection="Horizontal">
           </asp:RadioButtonList>
    </td>
    

    【讨论】:

    • 是的,这在本示例中有效,但在我使用 CSS 的页面上无效。似乎该行的某些 CSS 属性覆盖了“align=center”。因此,补救措施似乎是直接在单元格中添加 CSS 样式。不应该在其他上线 CSS 之前使用吗?
    • 使用 Chrome。如果我使用

      ,它在 VS2010 中呈现为居中,但是当我在浏览器中查看时,它又回到了左对齐。

    • 查看页面,radiobuttonlist 左对齐,hwere 是源 HTML。这是没有意义的。

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-02-06
    • 1970-01-01
    • 2015-04-18
    • 2011-09-03
    • 1970-01-01
    • 2011-11-30
    • 2011-06-30
    相关资源
    最近更新 更多