css text-overflow 超過寬度顯示省略符號

來源:互聯網
上載者:User
使用text-overflow:ellipsis對溢出文本顯示省略符號有兩個好處,一是不用通過程式限定字數;二是有利於SEO。需要使用對對溢出文本顯示省略符號的通常是文章標題列表,這樣處理對搜尋引擎更友好,因為標題實際上並未被截字,而是局限於寬度而未被顯示而已。通常的做法是這樣的:1.overflow:hidden;2.text-overflow:ellipsis;3.-o-text-overflow:ellipsis;4.white-space:nowrap;5.width:100%;其中,overflow: hidden和white-space: nowrap都是必須的否則不會顯示省略符號;-o-text-overflow: ellipsis針對Opera;而寬度的設定主要是針對IE6;該方法支援Internet Explorer, Safari, Chrome 和 Opera,但FF並不支援,不過可以通過Jquery來實作類別似的效果。下載這個Jquery外掛程式:jQuery ellipsis plugin調用方法:1.$(document).ready(function() {2.    $('.ellipsis').ellipsis();3.}
相關文章

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.