關於CSS文本超出div或者span時用省略符號代替的代碼

來源:互聯網
上載者:User
在項目中我們經常需要在文本過長時顯示,將文本超出的部分內容用省略符號代替,基於css代碼是怎麼實現的呢?下面指令碼之家小編通過分析本文給大家詳解,感興趣的朋友一起學習吧

在項目中我們經常需要在文本過長時顯示,將文本超出的部分內容用省略符號代替:
思想為:
首先設定寬度,然後讓超出的部分隱藏
如果有超出則在最後顯示省略符號
讓文本不換行
具體css代碼為:

.title{ width:200px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; word-break:keep-all; }

Html代碼就不用寫了,一個p 或者span class = "title"即可。

以上就是本文的全部內容,希望對大家的學習有所協助,更多相關內容請關注topic.alibabacloud.com!

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.