css自動截取字串且相容ie7 ff代碼

來源:互聯網
上載者:User

實列如下:

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

可用span或div引用,例如:

<span class=title>用戶端解決標題顯示太長省略多餘部分並加省略符號的樣式</span>

<div class=title>用戶端解決標題顯示太長省略多餘部分並加省略符號的樣式</div>

以上2例顯示在超過樣式定義的200px寬度後,後面的字元將被...替換.


上面的有不相容ie7 ff下面我作調整一下

<style type="text/css教程">

<!--

.div1{

 width:200px;

}

.div1 span{

   white-space:nowrap;

   text-overflow:ellipsis; /* for internet explorer */

   overflow:hidden;

   width:168px;

   display:block;

   float:left;

}


html>body .div1:after{/* for FF*/

   content: "...";

   margin-left:5px;

}


-->

</style>


<div class="div1"><span>最近微軟發布的IE7瀏覽器的相容性確實給一些網頁製作人員添加了一個沉重的負擔</span></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.