1. 程式人生 > >背景圖定位實現視覺錯屏效果,一般人都不知道的效果

背景圖定位實現視覺錯屏效果,一般人都不知道的效果

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        div{
            height: 100vh;
        }
        img{
            height: 100vh;
            width: 100%;
        }
        .img1{
            background-image:url(img/bt1.jpg);
            background-attachment: fixed;
            background-size: cover;
            background-position: center center;
        }
        .img2{
            background-image:url(imgs/2.jpg);
            background-attachment: fixed;
            background-size: cover;
            background-position: center center;
        }
        .img3{
            background-image:url(imgs/3.jpg);
            background-attachment: fixed;
            background-size: cover;
            background-position: center center;
        }
        .img4{
            background-image:url(imgs/4.jpg);
            background-attachment: fixed;
            background-size: cover;
            background-position: center center;
        }
    </style>
</head>
<body>
<div>1</div>
<div class="img1">2</div>
<div></div>
<div class="img2">2</div>
<div></div>
<div class="img3">2</div>
<div></div>
<div class="img4">2</div>
</body>
</html>