淺談——視覺滾差

先拋效果圖

 

 

 

 

 

 

 

核心屬性:background-attachment

核心代碼:

<!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>
        *{
            margin:0;
            padding:0;
        }
        section {
            height: 100vh;
            text-align:center;
            line-height:100vh;
            color:#fff;
            font-size:50px;
        }
        .g-word{
            background:#4e4e4e;
        }
        .g-img:nth-of-type(2) {
            background-image: url('./1.jpg');
        }
        .g-img:nth-of-type(4) {
            background-image: url('./2.jpg');
        }
        .g-img:nth-of-type(6) {
            background-image: url('./3.jpg');
        }
        .g-img{           
            background-attachment: fixed;
            background-size: cover;
            background-position: center center;
        }
    </style>
</head>

<body>
    <section class="g-word">Header</section>
    <section class="g-img">IMG1</section>
    <section class="g-word">Content1</section>
    <section class="g-img">IMG2</section>
    <section class="g-word">Content2</section>
    <section class="g-img">IMG3</section>
    <section class="g-word">Footer</section>
</body>

</html>

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章