|
table-layout:fixed 属性的解说 <table border=1 width=80><tr><td>abcdefghigklmnopqrstuvwxyz 1234567890</td></tr></table>
效果: ![]() 可以看到width=80并没有起作用,表格被字符撑开了。 例2:(IE浏览器)使用样式table-layout:fixed <style>.tbl {table-layout:fixed}</style><table class=tbl border=1 width=80><tr><td>abcdefghigklmnopqrstuvwxyz 1234567890</td></tr></table>
效果: ![]() width=80起作用了,但是表格换行了。 例3:(IE浏览器)使用样式table-layout:fixed与nowrap
<style>.tbl {table-layout:fixed}</style><table class=tbl border=1 width=80><tr><td nowrap>abcdefghigklmnopqrstuvwxyz 1234567890</td></tr></table>
效果: width=80起作用了,换行也被干掉了。 例4:(IE浏览器)在使用数值固定td大小情况下使用样式table-layout:fixed与nowrap
<style>.tbl {table-layout:fixed}</style><table class=tbl border=1 width=80><tr><td width=20 nowrap>abcdefghigklmnopqrstuvwxyz 1234567890</td><td nowrap>abcdefghigklmnopqrstuvwxyz 1234567890</td></tr></table>
效果: 不幸发生了,第一个td的nowrap不起作用了 例5:(IE浏览器)在使用百分比固定td大小情况下使用样式table-layout:fixed与nowrap
<style>.tbl {table-layout:fixed}</style><table class=tbl border=1 width=80><tr><td width=25% nowrap>abcdefghigklmnopqrstuvwxyz 1234567890</td><td nowrap>abcdefghigklmnopqrstuvwxyz 1234567890</td></tr></table>
效果: 改成百分比,终于搞定了例6:(Firefox浏览器)在使用百分比固定td大小情况下使用样式table-layout:fixed与nowrap效果:
把例5放到firefox下面,又ft了例7:(Firefox浏览器)在使用百分比固定td大小情况下使用样式table-layout:fixed与nowrap,并且使用div
<style>.tbl {table-layout:fixed}.td {overflow:hidden;}</style><table class=tbl border=1 width=80><tr><td width=25% class=td nowrap><div>abcdefghigklmnopqrstuvwxyz 1234567890</div></td><td class=td nowrap><div>abcdefghigklmnopqrstuvwxyz 1234567890</div></td></tr></table>
效果: 天下终于太平了 例8:(Firefox浏览器)在使用数值固定td大小情况下使用样式table-layout:fixed与nowrap,并且使用div
<style>.tbl {table-layout:fixed}.td {overflow:hidden;}</style>
<table class=tbl border=1 width=80><tr><td width=20 class=td nowrap><div>abcdefghigklmnopqrstuvwxyz 1234567890</div></td><td class=td nowrap><div>abcdefghigklmnopqrstuvwxyz 1234567890</div></td></tr></table>
效果: nowrap又不起作用了最终,例7是一个在IE和Firefox都可以完美解决页面强制换行问题的解决方案。
注意:去掉table的宽度在 firefox下是不正常的. 唉,IE的一些特有的东西也不全是坏事! |
个人试验,好象不行,且去掉宽度控制,屏幕不正规也不好看,晕,再试吧。
本文通过多个实例探讨了 CSS 中 table-layout:fixed 属性的使用方法及其与 nowrap 的结合应用,特别是在不同浏览器(如 IE 和 Firefox)下的表现差异。文章提供了在限定表格宽度时确保内容自动换行的解决方案。


width=80起作用了,换行也被干掉了。
不幸发生了,第一个td的nowrap不起作用了
改成百分比,终于搞定了
把例5放到firefox下面,又ft了
天下终于太平了
nowrap又不起作用了
886

被折叠的 条评论
为什么被折叠?



