日期:2014-05-16  浏览次数:20611 次

css 显示特定字符数量
============================
<style>
#idDIV{width:100%;height:90px;background-color:#87CEEB;padding:8px;overflow:hidden; text-overflow:ellipsis;white-space:nowrap; }
#idCodeDiv{width:100%;padding:4px;font-family:verdana,tahoma;margin:12px 0px 0px 0px;background-color:#EEEEEE;font-weight:bold;}
</style>

<script>
function rdl_change(e){
var oCodeDiv=document.all("idCodeDiv");
var oDiv=document.all("idDiv");
with (document.all("idSel1")) var sValue1=options[selectedIndex].value;
with (document.all("idSel2")) var sValue2=options[selectedIndex].value;
with (oDiv.style) {
overflow=sValue1;textOverflow=sValue2;
}
oCodeDiv.innerText="overflow : "+sValue1+"\r\n"+"text-overflow : "+sValue2+" ;";
}
</script>

<div id=idDIV>请您从下面的选择框中选择这段文字的相应属性的值。看一看会发生什么,然后您就会明白他们的意义。</div>
<br>
<table><tr><td>
<select id="idSel1" onchange="rdl_change();">
<option value="hidden">---overflow---
<option value="hidden">hidden
<option value="visible">visible
</select>
</td><td>
<select id="idSel2" onchange="rdl_change();">
<option value="clip">---text-overflow---
<option value="clip">clip
<option value="ellipsis" selected>ellipsis
</select>
</td></tr></table>
<div id=idCodeDiv>overflow : ellipsis ;<br>text-overflow : hidden ;</div>