日期:2014-05-17  浏览次数:21074 次

文字超出部分用省略号显示,并且鼠标经过时能显示完整文字提示信息
文字超出部分用省略号显示,并且鼠标经过时能显示完整文字提示信息,那位高人有代码啊!

------解决方案--------------------
这只是CSS功能,但在FF下不会出现省略号而已
HTML code
<style>
.scs{
    width:200px;font-size:12px;
    border:1px solid #ddd;
    overflow:hidden;
    text-overflow:ellipsis;
    white-space:nowrap;
</style>
<div class="scs" title="欢迎访问太阳光企业网站系统www.scscms.com">欢迎访问太阳光企业网站系统www.scscms.com</div>

------解决方案--------------------
<%
function check_str_length(str,num)
if len(str) > num then
check_str_length = left(str,num) & "..."
else
check_str_length = str
end if
end function
%>

<a href="" title="<%=rs("title")%>"><%=check_str_length(rs("title"),10)%></a>
------解决方案--------------------
CSS控制。
CSS 单行溢出文本显示省略号...的方法(兼容IE FF)(转)
------解决方案--------------------
楼上3位的方法都可以。
------解决方案--------------------
2F的方法不太好,当中英文混合时文字的长度会发生变化,最佳解决方案是1F+3F。
------解决方案--------------------
3楼正解
------解决方案--------------------
建议用CSS控制
------解决方案--------------------
如果想要完美的,就用程序实现截取:

VBScript code
<%
Function GetStringLength(txt,length)
dim i
i=1
y=0
txt=trim(txt)
for i=1 to len(txt)
j=mid(txt,i,1)
if asc(j)>=0 and asc(j)<=127 then '汉字外的其他符号,如:!@#,数字,大小写英文字母
y=y+0.5
else '汉字
y=y+1
end if
if -int(-y) >= length then '截取长度
txt = left(txt,i)
exit for
end if
next
response.write txt
End Function
%>

调用方法:
<%call GetStringLength(txt,length)%>
说明:txt为需截取的字符串,length为截取长度,一个汉字的长度按1个计算,一个英文或数字符号的长度按0.5个计算

把英文字母,数字,符号,汉字分开计算的长度截取:
GetString2.asp
<%
Function GetStringLength(txt,length)
dim i
i=1
y=0
txt=trim(txt)
for i=1 to len(txt)
j=mid(txt,i,1)
if asc(j)>=0 and asc(j)<=32 then '控制字符或通讯专用字符
y=y
elseif asc(j)>=33 and asc(j)<=47 then '标点符号 ! " # $ % & ' ( ) * + , - . /
y=y+0.5
elseif asc(j)>=48 and asc(j)<=57 then '数字 0123456789
y=y+0.5
num=num+1
elseif asc(j)>=58 and asc(j)<=64 then '标点符号 : ; < = > ? @
y=y+0.5
elseif asc(j)>=65 and asc(j)<=90 then '大写英文字母 ABCDEFGHIJKLMNOPQRSTUVWXYZ
y=y+0.5
beng=beng+1
elseif asc(j)>=91 and asc(j)<=96 then '标点符号 [ \ ] ^ _ `
y=y+0.5
elseif asc(j)>=97 and asc(j)<=122 then '小写英文字母 abcdefghijklmcopqrstuvwxyz
y=y+0.5
seng=seng+1
elseif asc(j)>=123 and asc(j)<=126 then '标点符号 { } ~
y=y+0.5
else
y=y+1
chn=chn+1
end if
if -int(-y) >= length then
txt = left(txt,i)
exit for
end if
next
End Function
%>

调用方法同上.