2010-06-14 52 views
7

我使用的表格中显示一组数据,我的HTML代码放在这里......在IE中的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> 

此表在Firefox,Safari和IE8工程确定。但问题出现在IE7,IE6中。当桌子扩展并离开屏幕(即在x轴右侧扩展)时.... 有没有修复它的方法?

IE6的IETester屏幕截图:

enter image description here

回答

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> 
在上面的代码中有三种变化

...

    在表中标记
  1. width属性是设置(改为将其设置为样式属性)
  2. col标签的宽度设置为与表格宽度相同
  3. 和TD的风格溢出设置为隐藏,(溢出:隐藏)。

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

0

尝试

<table border="1" cellspacing="0" cellpadding="0" width="780"> 
+0

没有它不与IE7和IE6工作..仍然扩大向右...... – 2010-06-14 06:37:19

+0

是它的只有你的页面上的内容可能是因为你在某个div中使用它而发生的。请检查它是否仅在给定的唯一代码时才会发生。 – Salil 2010-06-14 06:40:22

0

我一直在使用你的HTML只是测试它在IE6,IE8(兼容模式)和IE8看起来相同(普通模式)以及在Firefox中一样。

您的网页上的其他内容必须影响布局,因此请发布完整示例。

这是我测试过的完整例子。

<html> 
    <body> 
     <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> 
    </body> 
</html> 
+0

实际上这个表格是在后台使用PHP动态形成的...有header.php,footers.php和content.php形成这个页面... – 2010-06-14 07:23:47

+0

因此,向我们展示整个页面的重要性,以便我们可以重新创建问题。 – Fenton 2010-06-15 06:34:17

2

你也可以尝试一下风格word-break:break-all;

+0

我已经解决了我的问题......通过上面的回答....我会尝试使用word break规则,并检查它是否适用于所有浏览器......并且谢谢你@Rodeo Ramsey ... – 2010-06-17 06:00:23

+0

这种风格应该在哪里应用?需要看一个例子 – 2016-07-22 15:24:29

18

使用下面的CSS,这应该避免你的表超过最大尺寸定义:

table{ 
    table-layout:fixed; 
} 
+1

表格布局没有为我工作,通过尝试做了这项工作。 – 2011-06-14 14:02:14