zoukankan      html  css  js  c++  java
  • 滚动条与图片移动

    <html>
    <title>xxx</title>
    
    <head></head>
    
    <body>
        <div id="out" style="100%;height:1300px;position: absolute;">
            <hr />
            <div style="100%;height:100%">
                <img id="sImg" src="../Pictures/th.jpg" style="1200px;height:400px;position:absolute" />
            </div>
        </div>
    </body>
    <script>
        var yValue = 0;
        window.onscroll = scrollBottomOrTop;
        function scrollBottomOrTop() {
            if (yValue > window.scrollY) {
                var temp = yValue - window.scrollY
                move(temp);
            } else {
                var temp = yValue - window.scrollY
                move(temp);
            }
            yValue = window.scrollY;
            console.log(yValue);
        }
    
        var img = document.getElementById("sImg");
        img.top = 0;
        function move(k) {
            if (k > 0) {
                img.top = img.top - Math.abs(k);
            } else {
                img.top = img.top + Math.abs(k);
            }
    
            return img.style.top = img.top + 'px';
        }
    </script>
    
    </html>
    
    学贵有恒,而行胜于言
  • 相关阅读:
    查看网桥
    openstack 网卡
    fuel3.2安装
    whereis命令查看你要添加的软件在哪里
    ubuntu12.04开启远程桌面
    ubuntu 右键添加terminal
    本地源设置方法:
    ubuntu的dns设置
    chubu
    Linux内存
  • 原文地址:https://www.cnblogs.com/huangbinlooksgood/p/14198241.html
Copyright © 2011-2022 走看看