我如何说服IE遵守我的显式说明,使表列X像素宽? [英] How can I convince IE to honor my explicit instructions to make a table column X pixels wide?

查看:81
本文介绍了我如何说服IE遵守我的显式说明,使表列X像素宽?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请考虑这个小而完整的HTML块:

 <!DOCTYPE html& 
< html>
< head>
< title>测试< / title>
< style type =text / css>
span {overflow:hidden; white-space:nowrap; }
td {overflow:hidden; text-overflow:ellipsis}
< / style>
< / head>
< body>
< table cellspacing =0>
< tbody>
< tr>
< td nowrap =nowrapstyle =max-width:30px; width:30px; white-space:nowrap;>< span> column 1< / span>< / td&
< td nowrap =nowrapstyle =max-width:30px; width:30px; white-space:nowrap;>< span> column 2< / span>< / td>
< td nowrap =nowrapstyle =max-width:30px; width:30px; white-space:nowrap;>< span> column 3< / span>< / td&
< / tr>
< / tbody>
< / table>
< / body>
< / html>

如果在Chrome中渲染上述内容,您会看到我正在寻找的效果。 p>

但是在IE8或9中渲染它的宽度和/或最大宽度被忽略。



我如何得到IE只是让我明确指定单元格的宽度? (这也将是很好,如果我不必使用max-width让Chrome行为)。



BTW,我尝试了表的各种组合-layout:固定和使用colgroup与cols和各种类型,没有我试过说服IE做我明确要求它明确做。

解决方案

尝试样式:



table-layout:fixed; width:0px;}



你可以使用 max-width:30px / p>

你提到你使用 table-layout ,但是说明 width 这里做技巧


Please consider this small but complete chunk of HTML:

<!DOCTYPE html >
<html>
<head>
    <title>Test</title>
    <style type="text/css">
    span {overflow:hidden; white-space:nowrap;  }
    td {overflow:hidden; text-overflow:ellipsis}
    </style>
</head>
<body>
    <table cellspacing="0"  >
        <tbody>
            <tr>
               <td nowrap="nowrap" style="max-width:30px; width:30px; white-space:nowrap; "><span>column 1</span></td>
               <td nowrap="nowrap" style="max-width:30px; width:30px; white-space:nowrap; "><span>column 2</span></td>
               <td nowrap="nowrap" style="max-width:30px; width:30px; white-space:nowrap; "><span>column 3</span></td> 
             </tr>
        </tbody>
    </table>
</body>
</html>

If you render the above in Chrome you'll see the effect I'm looking for.

However render it in IE8 or 9 the width and/or max-width is ignored.

So my question is how do I get IE to simply let me specify the width of a cell explicitly? (It would also be nice if I didn't have to use max-width to get Chrome to behave either).

BTW, I've tried various combinations of table-layout:fixed and using colgroup with cols and all sorts, nothing I've tried convinces IE to do what I'm clearly asking it to explicitly do.

解决方案

Try on your table styling:

table {table-layout: fixed; width :0px;}

You can ditch the max-width:30px

You did mention you used table-layout, but stating the width here does the trick

这篇关于我如何说服IE遵守我的显式说明,使表列X像素宽?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆