• 小米手机图片(点击上班边图片向上走,点击下边向下走)


     1 <!DOCTYPE html>
     2 <html>
     3 <head lang="en">
     4     <meta charset="UTF-8">
     5     <title></title>
     6     <style>
     7         .xiaomi {
     8             width: 512px;
     9             height: 400px;
    10             border: 1px solid #f00;
    11             margin: 100px auto;
    12             overflow: hidden;
    13             position: relative;
    14         }
    15         .xiaomi span {
    16             position: absolute;
    17             left: 0;
    18             width: 100%;
    19             height: 200px;
    20             cursor: pointer;
    21         }
    22         .up {
    23             top: 0;
    24         }
    25         .down {
    26             bottom: 0;
    27         }
    28         #pic {
    29             position: absolute;
    30             top: 0;
    31             left: 0;
    32         }
    33     </style>
    34 </head>
    35 <body>
    36 <div class="xiaomi">
    37     <img src="mi.png" alt="" id="pic"/>
    38     <span class="up" id="picUp"></span>
    39     <span class="down" id="picDown"></span>
    40 </div>
    41 </body>
    42 </html>
    43 <script>
    44     function $(id) { return document.getElementById(id);}
    45     var num = 0; // 控制图片的top值
    46     var timer = null; // 定时器名称
    47     $("picUp").onmouseover = function(){
    48         // alert(11);
    49         clearInterval(timer);
    50         timer =  setInterval(function(){
    51             num -= 3;
    52             /** var aa=$("pic").offsetHeight-$("xiaomi").offsetHeight;**/
    53 
    54             num >= -1070 ? $("pic").style.top = num + "px" :  clearInterval(timer);
    55 
    56         },30);
    57     }
    58     $("picDown").onmouseover = function(){
    59         clearInterval(timer);
    60         timer  = setInterval(function(){
    61             num++;
    62             num < 0 ?  $("pic").style.top = num + "px" : clearInterval(timer);
    63         },30);
    64     }
    65     $("picUp").parentNode.onmouseout = function() {
    66         clearInterval(timer);
    67     }
    68 </script>
  • 相关阅读:
    高性能异步爬虫
    线程池在爬虫案例中的应用
    线程池的基本使用
    requests代理爬取
    python验证码识别
    获取人人网当前用户的个人详情页数据
    模拟登录人人网
    移远BC26基础开发之程序结构 三
    移远BC26基础开发之配置 二
    移远BC26/BC28(略)/MC20开发之环境搭建 一
  • 原文地址:https://www.cnblogs.com/yangguoe/p/8138054.html
Copyright © 2020-2023  润新知