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

兼容IE和Firefox火狐的上下、左右循环无间断滚动JS代码_javascript技巧

WBOY
Release: 2016-05-16 17:36:19
Original
1061 people have browsed it

html里的marqueen也能实现内容的滚动,但滚动是间断的,在滚动一个周期中,会有一段空白出现。如果滚动的区域比较大,空间的出现,会让页面看起来很不美观。运用JavaScript可以使这一问题得到改观,实现无间断的滚动。

上下循环滚动代码

复制代码 代码如下:



111111111111111

222222222222222

333333333333333

444444444444444

555555555555555



<script> <BR>var t=getid("demo"),t1=getid("demo1"),t2=getid("demo2"),sh=getid("show"); <BR>var inter; <BR>t2.innerHTML=t1.innerHTML; <BR>function qswhMarquee(){ <BR>if(t2.offsetTop<=t.scrollTop) <BR>t.scrollTop-=t1.offsetHeight; <BR>else <BR>t.scrollTop++; <BR>} <BR>inter=setInterval(qswhMarquee,30); <BR>function getid(id){ <BR>return document.getElementById(id); <BR>} <BR></script>

文字左右循环滚动代码
复制代码 代码如下:




余志国网站设计工作室提供专业的外贸网站建站服务。



Related labels:
source:php.cn
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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!