HTML中显示的文字自动换行

在html中控制自动换行

http://www.cnblogs.com/zjxbetter/articles/1323449.html

eg:

<table>
<tr>
<td width="200" style="word-break:break-all;">asdfsasdfasd扩大发射点法打发深刻发射点激发的发觉山地飞机啊飞机莱塞解放龙卷风啊fasasdfsasdfasdfasasdfsasdfasdfasasdfsasdfasdfasasdfsasdfasdfasasdfsasdfasdfasasdfsasdfasdfas</td>
</tr>
</table>

html中td自动换行

head>

<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<style type="text/css">
table

{
 border-collapse: collapse;
 border: 1px black solid;
}

tr td

{
 border: 1px black solid;
 height: 20px;
 text-align:center;
}


</style>
</head>
<body>
<table width="500" rules="all" style="table-layout:fixed">
  <tr>
    <td width="200px" rowspan="2" style="word-wrap : break-word ">
  内容内容  内容内容  内容内容  内容内容  内容内容
 </td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
</table>
</body>
</html>
View Code

 效果图

关于Asp.Net label的强制换行

第一种方法是直接引用样式:
<style type="text/css">
 .label{word-wrap:break-word;word-break:keep-all;overflow:hidden;}
</style>
<asp:Label ID="Label3" runat="server" Width="350px" Text='<%# Bind("y_question") %>' CssClass="label"></asp:Label>
复制代码
第二种方法:查看页面源码发现,解析后的label标签为<span>

所以在页面添加样式:

<style type="text/css">
span{word-break:break-all;}

</style>

<asp:Label ID="Label3" runat="server" Width="350px" Text='<%# Bind("y_question") %>' ></asp:Label>
 
View Code
原文地址:https://www.cnblogs.com/51net/p/4649716.html