background-attachment:fixed,背景图滚动切换视觉差效果

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>背景图实现视觉差的效果</title>
    <style>
        div.g-img {
            width: 100%;
            height: 100vh;
            text-align: center;
            line-height: 100vh;
            font-size: 50px;
            font-size: 700;
        }

        .g-img:nth-child(1) {
            background: url(http://pic1.win4000.com/wallpaper/2018-05-18/5afe820a3446b.jpg)center no-repeat;
            background-size: cover;
            background-attachment: fixed;
        }
        
        .g-img:nth-child(2) {
            background: url(http://pic1.win4000.com/wallpaper/2018-07-04/5b3c7fd2d66ff.jpg)center no-repeat;
            background-size: cover;
            background-attachment: fixed;
        }
        
        .g-img:nth-child(3) {
            background: url(http://pic1.win4000.com/wallpaper/2019-12-13/5df321951329d.jpg)center no-repeat;
            background-size: cover;
            background-attachment: fixed;
        }
        
        .g-img:nth-child(4) {
            background: url(http://pic1.win4000.com/wallpaper/6/5847b8f8a63db.jpg)center no-repeat;
            background-size: cover;
            background-attachment: fixed;
        }
    </style>
</head>

<body>
    <div class="g-img">section1</div>
    <div class="g-img">section2</div>
    <div class="g-img">section3</div>
    <div class="g-img">section4</div>

</body>

</html>
View Code

效果图如下:

posted @ 2020-01-17 15:29  面包_girl  阅读(521)  评论(0编辑  收藏  举报
/* 鼠标点击文字特效 */