Home > Web Front-end > JS Tutorial > body text

JS implements ultra-concise link list scrolling effect code in a fixed area

PHPz
Release: 2018-09-28 16:12:01
forward
1241 people have browsed it

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>
Copy after login

The above is the entire content of this chapter. For more related tutorials, please Visit JavaScript Video Tutorial!

Related labels:
source:jb51.net
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template