[url=http://www.w3school.com.cn/js/jsref_substring.asp]http://www.w3school.com.cn/js/jsref_substring.asp[/url]
[url=http://www.w3school.com.cn/jsref/jsref_substr.asp]http://www.w3school.com.cn/jsref/jsref_substr.asp[/url]
[b]第三个就是CSS的了[/b]
CSS截取主要使用text-overflow这个属性。
text-overflow: [ clip | ellipsis | <string> ]
text-overflow默认值为clip ,即当内容超出容器时,会裁切掉超出的文本,值为ellipsis时,会用省略号替代超出的文本;也可以用特定的字符串来替代超出的文本(目前仅 firefox 支持)。
省略号的例子:
[url=http://quirksmode.org/css/user-interface/textoverflow.html]http://quirksmode.org/css/user-interface/textoverflow.html[/url]
[url=https://developer.mozilla.org/en-US/docs/Web/CSS/text-overflow]https://developer.mozilla.org/en-US/docs/Web/CSS/text-overflow[/url]
其实css的说明看一下mozilla开发者网站的图例就明白了。在这里就不多说了。