如何用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>
相关推荐
Penge66613 小时前
React 事件处理:bind(this) 原理与实际开发常用写法
前端
ZhengEnCi13 小时前
小白用 AI 做官网完全指南:不用框架的六格清单,双击就能打开
前端·html·ai编程
zhanlang021713 小时前
HTML 零基础入门到企业实战【第五章 5.2】图片路径精讲:绝对路径、相对路径、网络路径(新手必踩坑点)
前端·html
夕水13 小时前
我用trae重构了ew-color-picker,一个插件化架构的现代颜色选择器
前端·javascript·开源
Penge66614 小时前
React JSX 核心语法:从入门到业务开发实战
前端
zhanlang021714 小时前
HTML 零基础入门到企业实战全套教程【第五章 5.5 综合案例:图文影音展示页面开发】
前端·html
zhanlang021714 小时前
HTML 零基础入门到企业实战全套教程【连载 5.3】audio、video 音频视频标签|兼容格式、自动播放踩坑、企业规范
前端·html
qq_4069810315 小时前
c++ lamda(三)Lambda表达式
java·前端·c++
zhanlang021715 小时前
HTML 零基础入门到企业实战【第五章 5.4】内嵌网页 iframe 标签:嵌入网页、视频、地图实战
前端·html·音视频
2分钟速写快排1 天前
孔乙己的茴字有多少种写法?|AI 对话实时通信的三种实现
前端·javascript·github