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

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM