滾動視差 background-attachment

 

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

<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<style>
section {
    height: 100vh;
}

.g-img {
    background-image: url(./back.jpeg);
    background-attachment: fixed;
    background-size: cover;
    background-position: center center;
}
</style>

<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>
相關文章
相關標籤/搜索