通常的文字截斷(適用於內聯與塊):
==============CSS================
.text-overflow{
display:block;/*內聯對象需加*/
width:31em;
word-break:keep-all;/* 不換行 */
white-space:nowrap;/* 不換行 */
overflow:hidden;/* 內容超出寬度時隱藏超出部分的內容 */
text-overflow:ellipsis;/* 當對象內文本溢出時顯示省略標記(...) ;需與overflow:hidden;一塊兒使用。*/
}
=================================css
對於表格的話,定義有一點不同:
==============CSS================
table{
width:30em;
table-layout:fixed;/* 只有定義了表格的佈局算法爲fixed,下面td的定義才能起做用。 */
}
td{
width:100%;
word-break:keep-all;/* 不換行 */
white-space:nowrap;/* 不換行 */
overflow:hidden;/* 內容超出寬度時隱藏超出部分的內容 */
text-overflow:ellipsis;/* 當對象內文本溢出時顯示省略標記(...) ;需與overflow:hidden;一塊兒使用。*/
}
=================================web
div中文字超過自動換行的css樣式算法
word-break:break-all;
overflow:hidden; 瀏覽器
---------------------------------佈局
word-wrap:break-word;spa