text-overflow樣式屬性值ellipsis的使用方法,overflowellipsis
一、div標籤中使用text-overflow樣式屬性值ellipsis的方法:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>div標籤中使用text-overflow樣式屬性值ellipsis的方法</title><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/></head><body><div style="width:200px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; border:1px solid #336699;">有志氣者不會甘居下遊,有見識者不敢自滿自足,有恒心者斷無不成之事!</div> </body></html>
二、table標籤子標籤td標籤中使用text-overflow樣式屬性值ellipsis的方法:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>table標籤子標籤td標籤中使用text-overflow樣式屬性值ellipsis的方法</title><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/></head><body><table cellSpacing="0" cellpadding="1" width="456" border="1" style="table-layout:fixed;"><tr><td style="text-overflow:ellipsis; overflow:hidden; white-space:nowrap; padding:2px;">有志氣者不會甘居下遊,有見識者不敢自滿自足,有恒心者斷無不成之事!</td></tr></table> </body></html>
說明:代碼二中的例子在某些瀏覽器(比如:Opera瀏覽器)中是達不到相應的效果的。
{text-overflow:ellipsis;}css裡的這個屬性在DW裡面的什地方?我怎找不到?
DW中沒有這種屬性,自己改css就是了 ,而且這個屬性FF不支援
CSS屬性text-overflow是在什地方插入的????
text-overflow有兩個屬性:
clip簡單剪下文本
ellipsis剪下文本後顯示省略符號
在div中單獨使用text-overflow是沒有效果的,必須下面兩個一起使用:
white-space:nowrap 強制不換行
overflow:hidden 溢出部分隱藏
例如:
<div style="width: 200px; height: 25px;text-overflow:ellipsis; white-space:nowrap;overflow:hidden">中華人民共和國中華人民共和國</div>
也可以寫個css式樣,class引用它。
<style type="text/css">
.mydiv{
text-overflow:ellipsis;
white-space:nowrap;
overflow:hidden;
width: 200px; height: 25px;
}
</style>
然後:
<div class="mydiv">中華人民共和國中華人民共和國</div>