视差标题移动到顶部页面

Parallax Caption move to top page

本文关键字:顶部 标题 移动 视差      更新时间:2023-09-26

我有问题的标题"TEST caption ",因为移动滚动后,标题逃到顶部。我需要同步标题与近图像。

[https://jsfiddle.net/ohamdcaL][1]
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>PARALLAX</title>
<style type="text/css">
    body {
        margin: 0px;
        background: url(http://th09.deviantart.net/fs70/PRE/i/2013/215/a/3/bubble_background_by_diversekitty-d6giw39.png) fixed;
        min-height: 2000px;
    }
    #content_layer {
        position: absolute;
        /*min-height: 100%;*/
    }
    #paralax_div1 {
        position:fixed;
        background: url(http://www.agencjaface.com/wp-content/uploads/marek_wlodarczyk_icon.jpg) no-repeat 600px 400px;
        width:100%;
        height:800px;
    }
    #caption {
        position: fixed;
        top: 500px;
        left: 300px;
        font-size: 20px;
        width:100%;
    }
</style>
    <script>
        function parallax() {
            var paralax_div1 = document.getElementById("paralax_div1");
            var caption = document.getElementById("caption");
            paralax_div1.style.top = -(window.pageYOffset / 80)+'px';
            caption.style.top = -(window.pageYOffset / 80)+'px';

        }
        window.addEventListener("scroll", parallax, false);
    </script>
</head>
<body>
    <div id="paralax_div1"></div>
    <div id="caption"> TEST CAPTION </div>
    <div id="content_layer">
        <script>
            for( i =0; i < 100; ++i) {
                document.write('HEHEHEHEHEH <BR/>');
            }
        </script>
    </div>
</body>
</html>