龙空技术网

两句css代码实现全屏滚动效果-demo案例

IT萌宠 101

前言:

现时各位老铁们对“html图片全屏”大概比较看重,同学们都需要学习一些“html图片全屏”的相关内容。那么小编同时在网上网罗了一些关于“html图片全屏””的相关文章,希望各位老铁们能喜欢,同学们快快来了解一下吧!

效果

两句css代码实现全屏滚动效果

html代码

<body>    <div class="container">        <section>            <h3>第一屏内容</h3>            <p>                在父容器上使用scroll-snap-type 属性 <br>                第一个参数y 是y轴捕捉位置 <br>                mandatory 超过距离则自动滚动到下一个容器 <br>                scroll-snap-type:y mandatory <br>                 在需要滚动的容器上使用 scroll-snap-align 属性 <br>                start 开始部分 end 结束部分 center 中间部分 <br>                scroll-snap-align:start; <br>            </p>        </section>        <section>            <h3>第二屏内容</h3>            <p>                在父容器上使用scroll-snap-type 属性 <br>                第一个参数y 是y轴捕捉位置 <br>                mandatory 超过距离则自动滚动到下一个容器 <br>                scroll-snap-type :y mandatory <br>                 在需要滚动的容器上使用 scroll-snap-align 属性 <br>                start 开始部分 end 结束部分 center 中间部分 <br>                scroll-snap-align:start; <br>            </p>        </section>        <section>            <h3>第三屏内容</h3>            <p>                在父容器上使用scroll-snap-type 属性 <br>                第一个参数y 是y轴捕捉位置 <br>                mandatory 超过距离则自动滚动到下一个容器 <br>                scroll-snap-type :y mandatory <br>                 在需要滚动的容器上使用 scroll-snap-align 属性 <br>                start 开始部分 end 结束部分 center 中间部分 <br>                scroll-snap-align:start; <br>            </p>        </section>    </div></body>
css代码
<style>    body {        margin: 0;    }     .container {        height: 100vh;        overflow-y: scroll;        scroll-snap-type: y mandatory;    }     section {        box-sizing: border-box;        padding: 112px;        height: 100%;        color: white;        scroll-snap-align: start;    }     section:nth-of-type(1) {        background-color: #60af15;    }     section:nth-of-type(2) {        background-color: #158baf;    }     section:nth-of-type(3) {        background-color: #af1581;    }</style>

标签: #html图片全屏