• 左右滚动的电影画布


    <!DOCTYPE html>
    <html lang="en">
        <head>
    <meta charset="utf-8">
            <style type="text/css">
                .box{
                     660px;
                    height: 500px;
                    margin: 100px auto;
                    overflow: hidden;
                    position: relative;
                }
                .box span{
                     330px;
                    height: 500px;
                    position: absolute;
                    top: 0;
                    cursor: pointer;
                }
                .box #left{
                    left: 0;
                }
                .box #right{
                    left: 330px;
                }
                .box #pic{
                    position: absolute;
                    top: 0;
                }
            </style>
            <script type="text/javascript">
                function $(id){return document.getElementById(id);}         
                window.onload = function(){
                    var step = 20;
                    var left = 0;
                    $('right').onmouseover = function(){
                        // alert($('pic').timer);
                        if($('pic').timer){
                            clearInterval($('pic').timer); 
                        }
                        $('pic').timer = setInterval(function(){
                            if(left > -1520){                      
                                left -= step;
                                $('pic').style.left = left + 'px';
                            }
                        }, 50);                   
                    }
                    $('left').onmouseover = function(){
                        // alert($('pic').timer);
                        if($('pic').timer){
                            clearInterval($('pic').timer)
                        }
                        $('pic').timer = setInterval(function(){
                            if(left < 0){
                                left += step;
                                $('pic').style.left = left + 'px';
                            }
                        }, 50);                   
                    }
                    var box = document.getElementsByClassName('box')[0];
                    box.onmouseout = function(){
                        clearInterval($('pic').timer);
                    }
                }
            </script>
        </head>
        <body>
            <div class="box">
                <img src="imgs/mj.jpg" alt="" id="pic">
                <span id="left"></span>
                <span id="right"></span>
            </div>
        </body>
    </html>
  • 相关阅读:
    Js获取当前日期时间及其它操作
    OpenResty
    Nginx开发从入门到精通
    TengineWeb服务器项目
    VS2012的SVN插件VISUALSVN
    VS项目如何运用svn的忽略列表
    SVN 中trunk、branches、tags都什么意思?
    SVN服务器搭建和使用(一)
    逗号分隔字符串转换为一张表--解决查询in(逗号分隔字符串)出错问题
    判断函数是否存在、判断函数是否存在并执行
  • 原文地址:https://www.cnblogs.com/mmit/p/11268737.html
Copyright © 2020-2023  润新知