滚动条与图片移动

<html>
<title>xxx</title>

<head></head>

<body>
    <div id="out" style="width:100%;height:1300px;position: absolute;">
        <hr />
        <div style="width:100%;height:100%">
            <img id="sImg" src="../Pictures/th.jpg" style="width: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>

滚动条与图片移动

上一篇:android studio报错:Connect to maven.google.com:443 [mavåen.google.com/216.58.200.238] failed: connect timed out。解决方案


下一篇:041*:(反射是什么?可以举出几个应用场景么?)(切面aop编程)(App 无痕埋点的思路了解么?你认为理想的无痕埋点系统应该具备哪些特点?)