Home  >  Article  >  Web Front-end  >  CSS- 文本超出指定宽度后隐藏并显示为省略号_html/css_WEB-ITnose

CSS- 文本超出指定宽度后隐藏并显示为省略号_html/css_WEB-ITnose

WBOY
WBOYOriginal
2016-06-24 11:54:33742browse

 

一般的文字截断(适用于内联与块):

.text-overflow {  

  display:block;/*内联对象需加*/   

  width:25em;  

  word-break:keep-all;/* 不换行 */   

  white-space:nowrap;/* 不换行 */  

  overflow:hidden;/* 内容超出宽度时隐藏超出部分的内容 */   

  text-overflow:ellipsis;/* 当对象内文本溢出时显示省略标记(...) ;需与overflow:hidden;一起使用。*/

}

对于表格文字溢出的定义:

对于表格超出范围显示省略号

table{  

   width:25em;  

   table-layout:fixed;/* 只有定义了表格的布局算法为fixed,下面td的定义才能起作用。 */

}

td{

  width:100%;  

  word-break:keep-all;/* 不换行 */   

  white-space:nowrap;/* 不换行 */    

  overflow:hidden;/* 内容超出宽度时隐藏超出部分的内容 */

  text-overflow:ellipsis;/* 当对象内文本溢出时显示省略标记(...) ;需与overflow:hidden;一起使用。*/

}

 

如:

------------------------------------------------------------------------------------------------

如果想鼠标悬停省略号显示内容就 在title 那里写好即可~

代码:

AAAAAAAAAAAAABBBBBBBBBBBBBCCCCCCCCCCCCCCDDDDDDDDDDDD

 

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn