如何用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>
相关推荐
Suppose5 分钟前
[css]旋转流光效果
css
丘山子15 分钟前
DNS 原理入门
前端·后端·面试
Kyle19941 小时前
RollCode:高效低代码开发新体验
前端
这是个栗子1 小时前
【Node.js安装注意事项】-安装路径不能有空格
前端·npm·node.js
源力祁老师1 小时前
外部系统获取Odoo数据最便捷的方式
开发语言·前端·javascript
用户9714171814271 小时前
picker-view选中框不居中
前端
YGY_Webgis糕手之路1 小时前
Cesium 快速入门(十) JulianDate(儒略日期)详解
前端·gis·cesium
燕山石头2 小时前
解决 IntelliJ IDEA Build时 Lombok 不生效问题
java·前端·intellij-idea
chancygcx_2 小时前
前端核心技术Node.js(二)——path模块、HTTP与模块化
前端·http·node.js