HTML表格th样式width不起作用

9

我有一个类似于下面这样的表格:

<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中没有。(可能是Firefox做得更正确)是否有什么方法可以使列的宽度在IE和Firefox中都固定为上述百分比?
4个回答

5

添加

样式="宽度:100%;"

到表格中。


2
你已经将百分比设置为百分比,但是百分比是相对于什么的?
尝试设置表格本身的宽度,可以使用style="width: x"或在CSS中设置:
table#MyTable {
    width: x;    // x denotes overall size
}

0
尝试将表格的宽度设置为100%。

0

我无法在IE、FF或Chrome中复制百分比的正确设置。要正确设置百分比,必须为外部表格设置宽度。无论是绝对值还是相对值都可以,但记住不要使用内联样式。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接