zoukankan      html  css  js  c++  java
  • 上下移动(鼠标在上半部分往上走,反之相反)

    <!DOCTYPE html>
    <html>
    <head lang="en">
    <meta charset="UTF-8">
    <title></title>
        
    <style>
            *{
                margin:0;
                padding:0;
            }
            .xiaomi{
                512px;
                height:400px;
                overflow:hidden;
                position:relative;
                margin:100px auto;
            }
            img{
                position:absolute;
                top:0;          
            }
            .xiaomi span{
                100%;
                height:200px;
                display:block;
                position:absolute;
                cursor:pointer;
            }
            .up{
                top:0;      
            }
            .down{
                bottom:0;           
            }
    </style>
    </head>
    <body>
    <div class="xiaomi" id="xiaomi">
    <img src="images/mi.png" alt="" id="pic"/>
    <span class="up" id="picUp"></span>
    <span class="down" id="picDown"></span>
    </div>
    </body>
    </html>
    <script src="../public.js"></script>
    <script>
        var timerUp = null,timerDown = null;
        var pic = $id("pic");
        $id("picUp").onmouseover = function(){
            timerUp = setInterval( function(){
                if( pic.offsetTop < -(1470-400) ){
                    clearInterval( timerUp );
                }else{
                    pic.style.top = pic.offsetTop - 2 + "px";
                }
            } , 30 )
        }
        $id("picUp").onmouseout = function(){
            clearInterval( timerUp );
        }
        $id("picDown").onmouseover = function(){
            timerDown = setInterval( function(){
                if( pic.offsetTop > 0 ){
                    clearInterval( timerDown );
                }else{
                    pic.style.top = pic.offsetTop + 3 + "px";
                }
            },30 )
        }
        $id("picDown").onmouseout = function(){
            clearInterval( timerDown );
        }
    </script>





  • 相关阅读:
    Python时间戳
    vux x-input 清除按钮不起作用
    MySQL连接查询流程源码
    Linux下用的脚本
    TableCache设置过小造成MyISAM频繁损坏 与 把table_cache适当调小mysql能更快地工作
    批量导入数据到InnoDB表速度优化
    DBA面对新mysql环境
    (进阶篇)PHP+Mysql+jQuery找回密码
    (进阶篇)PHP实现用户注册后邮箱验证,激活帐号
    (实用篇)php官方微信接口大全(微信支付、微信红包、微信摇一摇、微信小店)
  • 原文地址:https://www.cnblogs.com/tis100204/p/10319285.html
Copyright © 2011-2022 走看看