js 代码如下:

/***************滚动场次开始*****************/

function ScrollText(content, btnPrevious, btnNext, autoStart) {
this.Delay = ;
this.LineHeight = ;
this.Amount = ;
this.Direction = "up";
this.Timeout = ;
this.ScrollContent = this.$(content);
this.ScrollContent.innerHTML += this.ScrollContent.innerHTML;
//this.ScrollContent.scrollTop = 0;
if (btnNext) {
this.NextButton = this.$(btnNext);
this.NextButton.onclick = this.GetFunction(this, "Next");
this.NextButton.onmouseover = this.GetFunction(this, "Stop");
this.NextButton.onmouseout = this.GetFunction(this, "Start");
}
if (btnPrevious) {
this.PreviousButton = this.$(btnPrevious);
this.PreviousButton.onclick = this.GetFunction(this, "Previous");
this.PreviousButton.onmouseover = this.GetFunction(this, "Stop");
this.PreviousButton.onmouseout = this.GetFunction(this, "Start");
}
this.ScrollContent.onmouseover = this.GetFunction(this, "Stop");
this.ScrollContent.onmouseout = this.GetFunction(this, "Start");
if (autoStart) {
this.Start();
}
} ScrollText.prototype.$ = function (element) {
return document.getElementById(element);
} ScrollText.prototype.Previous = function () {
clearTimeout(this.AutoScrollTimer);
clearTimeout(this.ScrollTimer);
this.Scroll("up");
} ScrollText.prototype.Next = function () {
clearTimeout(this.AutoScrollTimer);
clearTimeout(this.ScrollTimer);
this.Scroll("down");
} ScrollText.prototype.Start = function () {
clearTimeout(this.AutoScrollTimer);
this.AutoScrollTimer = setTimeout(this.GetFunction(this, "AutoScroll"), this.Timeout);
} ScrollText.prototype.Stop = function () {
clearTimeout(this.ScrollTimer);
clearTimeout(this.AutoScrollTimer);
} ScrollText.prototype.AutoScroll = function () {
if (this.Direction == "up") {
if (parseInt(this.ScrollContent.scrollTop) >= parseInt(this.ScrollContent.scrollHeight) / ) {
this.ScrollContent.scrollTop = ;
}
this.ScrollContent.scrollTop += this.Amount;
} else {
if (parseInt(this.ScrollContent.scrollTop) <= ) {
this.ScrollContent.scrollTop = parseInt(this.ScrollContent.scrollHeight) / ;
}
this.ScrollContent.scrollTop -= this.Amount;
}
if (parseInt(this.ScrollContent.scrollTop) % this.LineHeight != ) {
this.ScrollTimer = setTimeout(this.GetFunction(this, "AutoScroll"), this.Delay);
} else {
this.AutoScrollTimer = setTimeout(this.GetFunction(this, "AutoScroll"), this.Timeout);
}
} ScrollText.prototype.Scroll = function (direction) {
if (direction == "up") {
if (this.ScrollContent.scrollTop == ) {
this.ScrollContent.scrollTop = parseInt(this.ScrollContent.scrollHeight) / ;
}
this.ScrollContent.scrollTop -= this.Amount;
} else {
this.ScrollContent.scrollTop += this.Amount;
}
if (parseInt(this.ScrollContent.scrollTop) >= parseInt(this.ScrollContent.scrollHeight) / ) {
this.ScrollContent.scrollTop = ;
}
if (parseInt(this.ScrollContent.scrollTop) % this.LineHeight != ) {
this.ScrollTimer = setTimeout(this.GetFunction(this, "Scroll", direction), this.Delay);
}
} ScrollText.prototype.GetFunction = function (variable, method, param) {
return function () {
variable[method](param);
}
} if (document.getElementById("ul_round")) {
var scrollup = new ScrollText("ul_round");
scrollup.LineHeight = ; //单排文字滚动的高度
scrollup.Amount = ; //注意:子模块(LineHeight)一定要能整除Amount.
scrollup.Delay = ; //延时
scrollup.Start(); //文字自动滚动
scrollup.Direction = "up"; //默认设置为文字向上滚动
}
/***************滚动场次结束*****************/

html代码:

<ul id="ul_round">
<li>今天上午场<b class="c_c00">:-:</b>,
已经结束
</li>
<li>今天下午场<b class="c_c00">:-:</b>,
已经结束
</li>
<li>今天临时场次<b class="c_c00">:-:</b>,
已经结束
</li> <li>今天上午场<b class="c_c00">:-:</b>,
已经结束
</li>
<li>今天下午场<b class="c_c00">:-:</b>,
已经结束
</li>
<li>今天临时场次<b class="c_c00">:-:</b>,
已经结束
</li>
</ul>

js 实现单行文本滚动效果的更多相关文章

  1. js实现文字上下滚动效果

    大家都知道,做html页面时,为了提升网页的用户体验,我们需要在网页中加入一些特效,比如单行区域文字上下滚动就是经常用到的特效.如下图示效果: <html> <head> &l ...

  2. js文字展示各种滚动效果

    js文字展示各种滚动效果:http://www.dowebok.com/demo/188/

  3. js 实现文字列表滚动效果

    今天要实现抽奖名单在首页滚动展示的效果,就用js写了一个,代码如下: html代码: <style type="text/css"> *{margin:;padding ...

  4. animate.css配合wow.min.js实现各种页面滚动效果

    有的页面在向下滚动的时候,有些元素会产生细小的动画效果.虽然动画比较小,但却能吸引你的注意.比如刚刚发布的 iPhone 6 的页面(查看).如果你希望你的页面也更加有趣,那么你可以试试 WOW.js ...

  5. js实现表格无缝滚动效果

    <!doctype html> <html> <head> <meta charset="utf-8"> <title> ...

  6. js实现页面消息滚动效果

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  7. WPF 文本滚动效果 渐变效果

    <DockPanel> <StackPanel DockPanel.Dock="Bottom" VerticalAlignment="Bottom&qu ...

  8. js实现新闻条目滚动效果

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  9. js实现简单易用的上下无缝滚动效果

    <!doctype html> <html> <head> <meta charset="utf-8"> <title> ...

随机推荐

  1. Smarty模板技术之foreach遍历数组实例全面讲解

    一.item属性用法 <?php $arr = array(, , ); $smarty->assign('testarrg', $arr); ?> 用Smarty中的foreach ...

  2. 织梦DedeCMS调用二级子栏目或者多级栏目解决方法

    本文是关于织梦DedeCMS调用多级子栏目的,拿来测试分享下.DEDECMS v5.7,后台已建栏目目录,如下图1所示: 图1 DEDECMS后台栏目结构 现在,我们先来调用顶级栏目"站长新 ...

  3. 爬虫的自我解剖(抓取网页HtmlUnit)

    网络爬虫第一个要面临的问题,就是如何抓取网页,抓取其实很容易,没你想的那么复杂,一个开源`HtmlUnit`包,4行代码就OK啦,例子如下: final WebClient webClient=new ...

  4. 利用nginx向现有网站添加登录验证功能(不添加修改现有网站代码)

    在不改变现有网站代码的前提下加入验证功能: 1.假设现有网站后端nodejs,端口3000,nginx配置如下 server { listen 80; server_name localhost; l ...

  5. 随鼠标移动的div

    <html> <head> <style type='text/css'> #d{ border:1px solid green; width:90px; heig ...

  6. <转>Npoi导入导出Excel操作<载>

    //Datatable导出Excel private static void GridToExcelByNPOI(DataTable dt, string strExcelFileName) { tr ...

  7. Mysql limit offset

    Mysql limit offset 假设数据库表student存在13条数据. 语句1:select * from student limit 9,4 语句2:slect * from studen ...

  8. [Effective JavaScript 笔记]第31条:使用Object.getPrototypeOf函数而不要使用__proto__属性

    ES5引入Object.getPrototypeOf函数作为获取对象原型的标准API,但由于之前的很多js引擎使用了一个特殊的__proto__属性来达到相同的目的.但有些浏览器并不支持这个__pro ...

  9. ruby Errors & Exceptions

    When you first started coding, errors were probably the last thing you wanted to see. After all, it’ ...

  10. First Missing Positive

    不好想,用桶排序解决. int findMissingPostive(int A[], int n) { bucket_sort(A, n); ; i < n; i++) ) ; ; } voi ...