≮崩溃≯不劳阁,俺的blog纯粹属于好玩,如有雷同 纯属巧合!
18 Mar
最原始的:
<%
if len(title) > 10 then ’判断字符串的长度
response.write left(rs("title"),9)&" ..."
else
response.write rs("title")
end if
%>
使用函数:
<%
function cutstr(str,strlen)
dim l,t,c
l=len(str)
t=0
for i=1 to l
c=abs(asc(mid(str,i,1)))
if c>255 then
t=t+2
else
t=t+1
end if
if t>=strlen then
cutstr=left(str,i)&".."
exit for
else
cutstr=str
end if
next
cutstr=replace(cutstr,chr(10),"")
end function
应用
response.write cutstr(title,10)
%>
使用css:
<style>
.csswidth{
width:340px;
overflow:hidden;
text-overflow:ellipsis;
white-space:nowrap;
font-weight:normal;
font-size:14px;
line-height:28px;
}
</style>
<div class=csswidth>这里的字不管有多长,其总长度总是css中定义的宽度,如果超过这个宽度就会自动用"点点点"来代替!!!</div>
注意把<>%都换成英文半角<>%
◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。