zoukankan      html  css  js  c++  java
  • 左右滚动的电影画布

    <!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>
  • 相关阅读:
    python各种类型转换-int,str,char,float,ord,hex,oct等
    python 时间戳
    在Adobe Reader中保存PDF表单数据的方法
    如何执行一个mysql的sql脚本文件
    在Apache中利用ServerAlias设置虚拟主机接收多个域名和设置域名泛解析
    utf8_general utf8_general utf8_bin区别
    CentOS 6.3 卷组挂载硬盘教程 linux的VPS如何分区
    【译】在C#中获取程序集比你想得要困难
    【译】.NET Core中的中介者模式-第二部分-Roll Your Own
    【译】.NET Core中的中介者模式-第一部分-什么是中介者
  • 原文地址:https://www.cnblogs.com/mmit/p/11268737.html
Copyright © 2011-2022 走看看