当前位置: 首页 > 工具软件 > parallax.js > 使用案例 >

parallax.js

长孙阳成
2023-12-01
parallax.js


<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/parallax/3.1.0/parallax.min.js"></script>
    <style>
        #scene{
            width: 500px;
            height: 300px;
            position: fixed;
            top: 50%;
            left: 50%;
            margin-top: -150px;
            margin-left: -250px;
            text-align: center;
        }
        #scene div{
            text-align: center;
            font-size: 25px;
            font-weight: 800;
        }
        .list{
            display: none;
        }
    </style>
</head>
<body>
    <div class="list">I love you very much</div>
    <div  id="scene">
        <div data-depth="0.5">Remember to write back to me</div>
    </div>
</body>
<script>
   var scene = document.getElementById('scene');
    var parallaxInstance = new Parallax(scene, {
        relativeInput: true,    
        clipRelativeInput: false,
        inputElement: null,     
        hoverOnly: false,     
        calibrateX: true,      
        calibrateY: true,       
        invertX: false,       
        invertY: false,
        limitX: 100,            
        limitY: 100,
        scalarX: 4.0,          
        scalarY: 4.0,
        frictionX: 0.2,          
        frictionY: 0.2,
        originX: 0.5,                         
        originY: 0.5,          
        pointerEvents: true,     
        onReady: null,
        selector: null
    });
    // parallaxInstance.friction(0.5, 0.5);
</script>
</html>
 类似资料:

相关阅读

相关文章

相关问答