|
使用CSS样式表让英文文本自动换行(2) <style> .tb{table-layout:fixed} </style> <table class="tbl" width="80"> <tr><td> abcdefghigklmnopqrstuvwxyz 1234567890 </td></tr> </table>
效果:可以自动换行
2.(IE浏览器)使用样式:
div css xhtml xml Example Source Code Example Source Code [www.52css.com] <style> .tb {table-layout:fixed} </style> <table class="tb" width="80"><tr><td nowrap> abcdefghigklmnopqrstuvwxyz 1234567890 </td></tr> </table>
效果:可以自动换行
3. (IE浏览器)在使用百分比固定td大小情况下使用样式table-layout:fixed与nowrap:
div css xhtml xml Example Source Code Example Source Code [www.52css.com] <style> .tb{table-layout:fixed} </style> <table class="tb" width=80> <tr> <td width=25% nowrap> abcdefghigklmnopqrstuvwxyz 1234567890 </td> <td nowrap>abcdefghigklmnopqrstuvwxyz 1234567890</td> </tr> </table>
效果:两个td均正常自动换行
4.(Firefox浏览器)在使用百分比固定td大小情况下使用样式table-layout:fixed与nowrap,并且使用div:
div css xhtml xml Example Source Code Example Source Code [www.52css.com] <style> .tb {table-layout:fixed} .td {overflow:hidden;} </style> <table class=tb 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>
这里单元格宽度一定要用百分比定义 效果:正常显示,但不能换行。
注:在FF下还没有能使容器内容换行的好方法,只能用overflow将多出的内容隐藏,以免影响整体效果。
|