前台特效(10)横向滚动字幕

<!-- longdd 2013.4.26 字幕横向滚屏-->
<!DOCTYPE html>
<html>
    <head>
        <title></title>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <script type="text/javascript" src="http://common.cnblogs.com/script/jquery.js"></script>
        <style type="text/css">
            #ScrollWord{
                width: 1000px;
                height: 30px;
                border: solid 1px #000;
                margin: 20px auto;
                overflow: hidden;
            }
            #ScrollCont{
                width: 2000px;
                height: 30px;
            }
            #div1{
                float:left;
                width: 1000px;
                height: 30px;
                line-height: 30px;
            }
            #div2{
                float:left;
                width: 1000px;
                height: 30px;
                line-height: 30px;
            }
        </style>
        <script>
            $(function() {
                //复制div1内容到div2
                $("#div2").html($("#div1").html());

                //定时器
                var scroll = setInterval(scrolls, 150);
                //滚动函数
                function scrolls() {
                    if ($("#ScrollWord").scrollLeft() >= $("#div2").width()) {
                        $("#ScrollWord").scrollLeft($("#ScrollWord").scrollLeft() - $("#div1").width());
                    } else {
                        $("#ScrollWord").scrollLeft($("#ScrollWord").scrollLeft() + 5);
                    }
                }
                //鼠标悬停停止
                $("#ScrollWord").mouseover(function() {
                    clearInterval(scroll);
                });
                //鼠标离开继续
                $("#ScrollWord").mouseout(function() {
                    scroll = setInterval(scrolls, 150);
                });
            });
        </script>
    </head>
    <body>
        <div id="ScrollWord">
            <div id="ScrollCont">
                <div id="div1">
                    <span>我叫龙弟弟 我叫龙弟弟我叫龙弟弟我叫龙弟弟我叫龙弟弟 我叫龙弟弟end</span>
                </div>
                <div id="div2"></div>
            </div>
        </div>
    </body>
</html>

 

转载于:https://www.cnblogs.com/longdidi/archive/2013/04/26/3045209.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值