IE下换行很简单
|
1
2
3
4
|
.table1 td{ word-break: break-all; word-wrap: break-word;} |
word-wrap:
normal Default. Content exceeds the boundaries of its container.
break-word Content wraps to next line, and a word-break occurs when necessary.
word-break:
normal Default. Allows line breaking within words.
break-all Behaves the same as normal for Asian text, yet allows the line to break arbitrarily for non-Asian text. This value is suited to Asian text that contains some excerpts of non-Asian text.
keep-all Does not allow word breaking for Chinese, Japanese, and Korean. Functions the same way as normal for all non-Asian languages. This value is optimized for text that includes small amounts of Chinese, Japanese, or Korean.
可是火狐没让你那么轻易,在没有设定宽度的情况下是无法换行的,所以你得设个宽给它,很郁闷,碰到做成控件的表格的时候麻烦啊,在插入表格的内容前后用个
|
1
|
<div class="tdWrap">content</div> |
在给tdWrap一个width的属性。也试过用js计算宽度,再把样式写上去,这个可能比较适合不确定宽的情况,呵呵,笨,不知道又没更好的(以上仅针对个人所遇到的情况,且针对表格里的内容)。
js计算宽度
|
1
2
3
4
5
6
7
|
//firefox超长字符串处理,文字在有ID的div,且有以上样式,如果是class,可以遍历function firefoxLongString(elementID,width) { if (navigator.userAgent.indexOf("Firefox") > 0) { var w =width; document.getElementById(elementID).style.width = w + "px"; }} |
扩展下,不换行
|
1
2
3
|
.nowrap{ white-space:nowrap;} |
所有浏览器都支持 white-space 属性,不过任何的版本的 Internet Explorer (包括 IE8)都不支持属性值 “inherit”。

