做项目时遇到了一个问题,在firefox下可以自动换行,可是在chrome下不可以呢,在td中设置style就可以了<td align='left' style='word-break:break-all;word-wrap:break-word'>
总结了一下:
{CSS設定}
<style type="text/css">
/*自动换行,IE,Chrome通用,FireFox连续英文不换行(遇空格换一行)*/
.AutoNewline_break{word-wrap:break-word; word-break:break-all; }
.AutoNewline_normal{word-wrap:break-word; word-break:normal; }
/*強制不换行,IE,FireFox,Chrome通用*/
.NoNewline{white-space:nowrap}
/*标签继承*/
div { background:red; word-wrap: break-word; word-break:break-all; }
</style>
{HTML設定}
<table width="100" border="1" style="width:100;">
<tr><td>
<div>
自动换行自动换行自动换行自动换行自动换行自动换行自动换行自动换行自动换行自动换行自动换行自动换行自动换行自动换行自动换行kkkInternationalInternationalInternationalInternational
</div>
</td></tr>
</table>
---或者---------------
<table width="200" border="0" cellspacing="0" cellpadding="0"><tr>
<td class="AutoNewline_normal">
<div style="width:100%; word-wrap: break-word; word-break: normal;">
1111111111111 2222222222 3333333333 44444 555555555555555555
</div>
</td>
</tr>
</table>
</table>
##直接对全部设定
GridView1.Attributes.Add("style", "word-break:keep-all;word-wrap:normal"); //正常换行
GridView1.Attributes.Add("style", "word-break:break-all;word-wrap:break-word"); //自动换行