如何用css做出酷炫的视差滚动效果

复制代码
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
       div {
        height: 100vh;
        background: rgba(0, 0, 0, .7);
        color: #fff;
        line-height: 100vh;
        text-align: center;
        font-size: 20vh;
        }
        .a-img1 {
        background-image: url(https://images.pexels.com/photos/1097491/pexels-photo-1097491.jpeg);
        background-attachment: fixed;
        background-size: cover;
        background-position: center center;
        }
        .a-img2 {
        background-image: url(https://images.pexels.com/photos/2437299/pexels-photo-2437299.jpeg);
        background-attachment: fixed;
        background-size: cover;
        background-position: center center;
        }
        .a-img3 {
        background-image: url("https://images.pexels.com/photos/1005417/pexels-photo-1005417.jpeg");
        background-attachment: fixed;
        background-size: cover;
        background-position: center center;
        }
       </style>
</head>
<body>
       <div class="a-text">1</div>
       <div class="a-img1">2</div>
       <div class="a-text">3</div>
       <div class="a-img2">4</div>
       <div class="a-text">5</div>
       <div class="a-img3">6</div>
       <div class="a-text">7</div>
</body>
</html>
相关推荐
用户8168694747251 分钟前
React 如何用 MessageChannel 模拟 requestIdleCallback
前端·react.js
heyCHEEMS3 分钟前
手搓 uniapp vue3 虚拟列表遇到的坑
前端
Duck不必5 分钟前
紧急插播:CVSS 10.0 满分漏洞!你的 Next.js 项目可能正在裸奔
前端·next.js
幸运小圣5 分钟前
动态组件【vue3实战详解】
前端·javascript·vue.js·typescript
用户413079810616 分钟前
终于不漏了-Android开发内存泄漏详解
前端
孟祥_成都6 分钟前
nest.js / hono.js 一起学!hono的设计思想!
前端·node.js
努力glow .7 分钟前
彻底解决VMware下ROS2中gazebo启动失败的问题
前端·chrome
阿笑带你学前端8 分钟前
开源记账 App 一个月迭代:从 v1.11 到 v2.2,暗黑模式、标签系统、预算管理全面升级
前端
AAA阿giao10 分钟前
浏览器底层探秘:Chrome的奇妙世界
前端·chrome·gpu·多进程·单进程·v8引擎·浏览器底层
王兆龙16814 分钟前
Vue3组件传值
前端·javascript·vue.js