This article mainly introduces JS to implement ultra-concise link list scrolling effect code in a fixed area, very common page element attribute transformation control to achieve scrolling effect, simple and practical, friends in need can refer to it, the details are as follows:
This ultra-lite version of the link list text scrolling code can scroll within the specified area. Of course, the area size can be set by yourself.
A screenshot of the running effect is as follows:
The online demo address is as follows:
http://demo.jb51.net/ js/2015/js-link-list-scroll-style-codes/
The specific code is as follows:
<html> <HEAD> <TITLE>文字链接列表滚动</TITLE> <META content="text/html; charset=gb2312" http-equiv=Content-Type> <STYLE type=text/css> #demo a { width:100%; overflow:hidden; font:12px/16px tahoma; display:block; text-decoration:none; margin:2px; color:#4a551c; padding-left:2px; text-align:left; } #demo a:hover { color:#ff6600; } </STYLE> </HEAD> <body> <p id="demo" style="overflow:hidden;height:132px;width:350px; border:1px solid #dde5bc;"> <p id="demo1"> <a href="#">多彩的电脑机箱图标,很多颜色和风格……</a> <a href="#">地方税务局网站建设方案 ……</a> <a href="#">获得系统内存,并以圆饼图表现百分比……</a> <a href="#">多彩的电脑机箱图标,很多颜色和风格……</a> <a href="#">完全兼容IE, FF, Opera, 其它的还未经测试……</a> <a href="#">地方税务局网站建设方案 ……</a> <a href="#">多彩的电脑机箱图标,很多颜色和风格……</a> <a href="#">地方税务局网站建设方案 ……</a> <a href="#">完全兼容IE, FF, Opera, 其它的还未经测试……</a> <a href="#">获得系统内存,并以圆饼图表现百分比……</a> <a href="#">完全兼容IE, FF, Opera, 其它的还未经测试……</a> <a href="#">获得系统内存,并以圆饼图表现百分比……</a> </p> <p id="demo2"></p> </p> <script> var speed=40 var demo=document.getElementById("demo"); var demo2=document.getElementById("demo2"); var demo1=document.getElementById("demo1"); demo2.innerHTML=demo1.innerHTML function Marquee(){ if(demo2.offsetTop-demo.scrollTop<=0) demo.scrollTop-=demo1.offsetHeight else{ demo.scrollTop++ } } var MyMar=setInterval(Marquee,speed) demo.onmouseover=function() {clearInterval(MyMar)} demo.onmouseout=function() {MyMar=setInterval(Marquee,speed)} </script> </body> </html>
The above is the entire content of this chapter. For more related tutorials, please Visit JavaScript Video Tutorial!