【问题标题】:HTML Table th style width not workingHTML Table th 样式宽度不起作用
【发布时间】:2011-07-11 01:41:25
【问题描述】:

我有一张这样的桌子:

<table id="MyTable" cellspacing="0" cellpadding="0">
    <thead>
        <tr>
            <th style="width: 30%;">
                <asp:Literal ID="LitDescriptionTitle" runat="server" />
            </th>
            <th style="width: 30%;">
                <asp:Literal ID="LitDescription2Title" runat="server" />
            </th>
            <th style="width: 30%;">
                <asp:Literal ID="LitAddressTitle" runat="server" />
            </th>
            <th style="width: 10%;">
                &nbsp;
            </th>
        </tr>
    </thead>
<tbody>

现在列宽在 IE 中正确设置为百分比,但在 Firefox 中没有。 (大概是FF做对了)

我可以做些什么来让列的宽度在 IE 和 FF 中都固定为上述百分比?

【问题讨论】:

    标签: html html-table width


    【解决方案1】:

    尝试为表格添加 100% 的宽度。

    【讨论】:

      【解决方案2】:

      添加

      style="宽度:100%;"

      上桌

      【讨论】:

        【解决方案3】:

        我无法复制在 IE、FF 或 Chrome 中正确设置的百分比。要正确设置百分比,您必须为外围表设置宽度。这是绝对值还是相对值取决于您。但请记住不要使用内联样式。

        【讨论】:

          【解决方案4】:

          您已将百分比设置为百分比,但百分比是什么?

          尝试设置表格本身的宽度,可以使用style="width: x" 或在 CSS 中使用:

          table#MyTable {
              width: x;    // x denotes overall size
          }
          

          【讨论】:

            猜你喜欢
            • 1970-01-01
            • 1970-01-01
            • 2013-11-17
            • 2012-06-27
            • 2012-09-29
            • 2012-03-01
            • 1970-01-01
            • 2012-09-07
            • 1970-01-01
            相关资源
            最近更新 更多