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>
效果: ![]() 例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>
效果: ![]() 例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效果:
![]() 例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>
效果: ![]() 最终,例7是一个在IE和Firefox都可以完美解决页面强制换行问题的解决方案。
注意:去掉table的宽度在 firefox下是不正常的. 唉,IE的一些特有的东西也不全是坏事! |
个人试验,好象不行,且去掉宽度控制,屏幕不正规也不好看,晕,再试吧。