Use two divs to nest link text, set the outermost div to overflow:hidden, and use js to dynamically control its width to achieve expansion and contraction.
nbsp;html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
Demo of news wheel display a { font-size:14px}
#box { width:400px; height:20px; overflow:hidden;}
#title { color:#000;width:400px; height :20px;font-size:14px;line-height:18px; /*background-color:#FF0000*/}
<script> <BR>var handle; <BR>var handle2; <BR>var boxW=0; <BR>var titleNum=0; <BR>function init(){ <BR> var newsTitles = "快乐笛子的博客|中央统战部:新社会阶层纳入中国统一战线|中俄明年将在俄远东地区举行联合反恐演|广州宾馆3小时内须将旅客信息传给公安机关|国亲将推动弹劾陈水扁案"; <BR> var newsLinks = "http://www.happyshow.org|http://news.sina.com.cn/c/2006-09-02/093410901015.shtml|http://news.sina.com.cn/c/2006-09-02/02069914065s.shtml|http://news.sina.com.cn/c/2006-09-02/043210898986.shtml|http://news.sina.com.cn/c/2006-09-02/06069915455s.shtml"; <BR> document.getElementById("box").style.width = "400px"; <BR> document.getElementById("title").innerHTML = "<a target='_blank' href='"+newsLinks.split("|")[titleNum]+"'>"+newsTitles.split("|")[titleNum]+""; <BR> //setTimeout("decreaseBoxW();",1500); <BR> titleNum++; <BR> setInterval("innerTitle('"+newsTitles+"','"+newsLinks+"')",3100); <BR>} <BR>function innerTitle(titles,links){ <BR> var t = titles.split("|"); <BR> var a = links.split("|"); <BR> if (!t[titleNum]) <BR> titleNum=0; <BR> document.getElementById("box").style.width = "0px"; <BR> document.getElementById("title").innerHTML = "<a target='_blank' href='"+a[titleNum]+"'>"+t[titleNum]+""; <BR> handle2 = setInterval("increaseBoxW()",1);//展开 <BR> titleNum++; <BR>} <BR>function increaseBoxW(){ <BR> boxW = parseInt(document.getElementById("box").style.width); <BR> boxW = boxW + 4; <BR> if (boxW>400){ <BR> clearInterval(handle2); <BR> document.getElementById("box").style.width = "400px"; <BR> setTimeout("decreaseBoxW()",1500) <BR> }else{ <BR> document.getElementById("box").style.width = boxW+"px"; <BR> } <BR>} <BR>function decreaseBoxW(){ <BR> handle = setInterval("decreaseBoxW2()",4) <BR>} <BR>function decreaseBoxW2(){ <BR> boxW = parseInt(document.getElementById("box").style.width); <BR> boxW = boxW - 16; <BR> if(boxW<0){ <BR> clearInterval(handle); <BR> document.getElementById("box").style.width = "0px"; <BR> }else{ <BR> document.getElementById("box").style.width = boxW + "px"; <BR> } <BR>} <BR></script><script> <BR>init(); <BR></script>
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn