CSS實現在FireFox下截取字串顯示省略符號

來源:互聯網
上載者:User

使用CSS截取字串並顯示成省略符號是一個比較實用的功能,將需要截取的時候交給CSS前端來處理,減少伺服器資源浪費,使網頁速度更快,但是有時候由於瀏覽器的相容性,致使CSS截取字串在IE和Firefox下的處理方式並不相同,本代碼是解決了Firefox下的CSS截取字串問題。
--------------------------------css樣式-------------------------------------

<style><style type="text/css"><!--body{ font-family: 宋體; font-size: 12px; color: #333333;}.div1{width:200px;}.div1 a{   white-space:nowrap;   text-overflow:ellipsis; /* for internet explorer */   overflow:hidden;   width:168px;+width:200px;_width:200px;   display:block;   float:left;   }html>body .div1:after{   content: "...";   margin-left:5px;}--></style>

---------------------------------------html------------------------

<div class="div1"><a href="#">用CSS截取字串並顯示成省略符號是一個比較實用的功能,將需要截取的時候交給CSS前端來處理</a></div>

相關文章

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.