1.(IE浏览器)white-space:normal; word-break:break-all;这里前者是遵循标准。
#wrap{white-space:normal; width:200px; }
或者
#wrap{word-break:break-all;width:200px;}
eg.
<div id="wrap">ddd1111111111111111111111111111111111111111111111111111111111111111111</div>
2.(Firefox浏览器)white-space:normal; word-break:break-all;overflow:hidden;同样的FF下也没有很好的实现方法,只能隐藏或者加滚动条,当然不加滚动条效果更好!
#wrap{white-space:normal; width:200px; overflow:auto;}
或者
#wrap{word-break:break-all;width:200px; overflow:auto; }
eg.
<div id="wrap">ddd1111111111111111111111111111111111111111111111111111111111111111111</div>
3.(IE浏览器)使用样式table-layout:fixed;
eg.
<style>
.tb{table-layout:fixed}
</style>
<table class="tbl" width="80">
<tr>
<td>abcdefghigklmnopqrstuvwxyz 1234567890
</td>
</tr>
</table>
4.(IE浏览器)使用样式table-layout:fixed与nowrap
eg.
<style>
.tb {table-layout:fixed}
</style>
<table class="tb" width="80">
<tr>
<td nowrap>abcdefghigklmnopqrstuvwxyz 1234567890
</td>
</tr>
</table>
5. (IE浏览器)在使用百分比固定td大小情况下使用样式table-layout:fixed与nowrap
<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>
6.(Firefox浏览器)在使用百分比固定td大小情况下使用样式table-layout:fixed与nowrap,并且使用div
eg.
<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>
文本框自动换行和文字对齐的实现
原创文章如转载,请注明:转载自悠悠博客 [ http://www.ajaxstu.com/ ]
相关文章:
- onsubmit="return false;"(2007-10-25 4:0:0)
- 限制TextArea区的文字输入数量(2007-9-26 6:30:36)
- 判断checkbox是否至少有选择一项(2007-9-12 8:42:1)
- HTML元素 - select(2007-9-6 6:16:28)
- HTML元素 - textarea(2007-8-21 2:27:35)
- 向文本框输出数据的函数(2007-8-9 2:15:49)
- ASP表单与用户输入区域(2007-8-7 1:27:35)
- 可编辑的SELECT(2007-7-5 9:14:19)
- 简单的表单验证(后台验证)(2007-7-3 4:27:19)
- ASP连动下拉列表从数据库读取(2007-6-20 1:45:55)
◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。
