IE中的HTML表格宽度?

Har*_*rup 8 html css html-table

我使用表来显示一组数据,我的HTML代码在这里...

<table border="1" cellspacing="0" cellpadding="0" style="width: 780px;">
  <tbody>
    <tr>
      <td style="width: 780px; height: 25px;">
        <pre width='100' style='width: 780px; word-wrap: break-word;'>
            the data goes here.....
        </pre>            
      </td>
    </tr>
    <tr>
      <td style="width: 780px; height: 25px;">
        <pre width='100' style='width: 780px; word-wrap: break-word;'>
            the data goes here.....
        </pre>            
      </td>
    </tr>
  </tbody>
</table>
Run Code Online (Sandbox Code Playgroud)

这个表在firefox,safari和IE8中运行正常.但问题出现在IE7,IE6中.当桌子扩展并离开屏幕时(即在x轴向右侧扩展)....有没有修复它的黑客?

IETester中IE6的屏幕截图:

在此输入图像描述

小智 19

使用下面的CSS,这可以防止您的表超出您定义的最大大小:

table{
  table-layout:fixed;
}
Run Code Online (Sandbox Code Playgroud)


Har*_*rup 2

问题已解决,因为我使用的代码为

<table border="1" cellspacing="0" cellpadding="0" width="780" style="table-layout:fixed">
<col width="780">
<tbody>
<tr>
  <td style="width: 780px; height: 25px; overflow:hidden;">
    <pre width='100' style='width: 780px; word-wrap: break-word;'>
        the data goes here.....
    </pre>            
  </td>
</tr>
<tr>
  <td style="width: 780px; height: 25px; overflow:hidden;">
    <pre width='100' style='width: 780px; word-wrap: break-word;'>
        the data goes here.....
    </pre>            
  </td>
</tr>
</tbody>
</table>
Run Code Online (Sandbox Code Playgroud)

上面的代码有三处变化......

  1. 在表格标签中设置宽度属性(而不是在样式属性中设置)
  2. col标签设置的宽度与表格宽度相同
  3. 在TD的风格中,溢出被设置为隐藏(overflow:hidden)。

我从下面给出的链接中得到了此信息,请大家查看...“ http://www.tek-tips.com/faqs.cfm?fid=4499 ”,因此我的问题得到了解决。