如何用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>
相关推荐
掘金者阿豪12 分钟前
打通KingbaseES与MyBatis:一篇详尽的Java数据持久化实践指南
前端·后端
RoyLin1 小时前
TypeScript设计模式:原型模式
前端·后端·node.js
我是天龙_绍1 小时前
vue Composables 组合式函数
前端
zjjuejin1 小时前
Maven项目的核心蓝图:POM文件
前端·maven
小气小憩1 小时前
“暗战”百度搜索页:Monica悬浮球被“围剿”,一场AI Agent与传统巨头的流量攻防战
前端·人工智能
前端付豪1 小时前
1、震惊!99% 前端都没搞懂的 JavaScript 类型细节
前端·javascript·面试
朝与暮1 小时前
js符号(Symbol)
前端·javascript
恋猫de小郭2 小时前
对于普通程序员来说 AI 是什么?AI 究竟用的是什么?
前端·flutter·ai编程
大怪v2 小时前
前端:人工智能?我也会啊!来个花活,😎😎😎“自动驾驶”整起!
前端·javascript·算法
我是天龙_绍2 小时前
vue3 props 如何写ts,进行类型标注
前端