使用純CSS3截取字串

來源:互聯網
上載者:User
這次給大家帶來使用純CSS3截取字串,的注意事項有哪些,下面就是實戰案例,一起來看一下。

代碼執行個體如下:

<!DOCTYPE html><html><head><meta charset=" utf-8"><meta name="author" content="http://www.jb51.net/" /><title>CSS</title><style type="text/css"> #first{  width:120px;  height:30px;  background-color:#F30;  overflow:hidden;  text-overflow:clip;  white-space:nowrap;}#second{  width:120px;  height:30px;  background-color:#F30;  overflow:hidden;  text-overflow:ellipsis;  white-space:nowrap;  margin-top:10px;}</style> </head><body><p id="first">QWEQWEQWEQWE</p> <p id="second">QWEQWEQWEQWE</p> </body></html>

特別注意的是:不能夠省略white-space:nowrap和overflow:hidden,否則截取字串無效。

相信看了本文案例你已經掌握了方法,更多精彩請關注php中文網其它相關文章!

推薦閱讀:

小程式開發做出快顯功能表功能(附代碼)

webpack升級到4.0版本並且安裝webpack-cli

相關文章

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.