您好,请您试试下面的方法 {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> ------------------------------------------------------------------------------- {ASP.NET - GridView} ##直接对全部设定 GridView1.Attributes.Add("style","word-break:keep-all;word-wrap:normal"); //正常换行GridView1.Attributes.Add("style","word-break:break-all;word-wrap:break-word"); //自动换行 ##针对特定项目,在RowDataBound设定e.Row.Cells[2].Style.Add("word-break","break-all");
#CSS#在设定table为百分比时,如何实现火狐,Chrome下TD内容文字超出时自动换行?
最新推荐文章于 2022-03-21 15:48:50 发布