【问题标题】:scroll snapping Issue滚动捕捉问题
【发布时间】:2021-12-04 22:50:46
【问题描述】:

我正在创建一个登录页面,其中顶部具有正常滚动,然后是启用滚动捕捉的容器,然后是正常滚动容器。但是当我启用滚动捕捉时,我无法移出中间容器。我看不到上半部,也看不到下半部。

这是启用滚动捕捉的容器

.scrollcontainer {
  scroll-snap-type: y mandatory;
  overflow-y: scroll;
  height: 100vh;
}

.scrollcontainer section {
  height: 100vh;
  scroll-snap-align: start;
}
<div class="scrollcontainer">
  <section class="firstpiece">
    <h1>First page</h1>
  </section>
  <section class="secondpiece">
    <h1>Second page</h1>
  </section>
  <section class="thirdpiece">
    <h1>Third page</h1>
  </section>
</div>

我做错了什么?

【问题讨论】:

    标签: html css scroll-snap


    【解决方案1】:

    试试这个:

    html {
        scroll-snap-type: y mandatory;
    }
    
    
    section {
      border-bottom: 1px solid black;
        height: 100vh;
        scroll-snap-align: start;
    }
    <section class="firstpiece">
        <h1>First page</h1>
      </section>
      <section class="secondpiece">
        <h1>Second page</h1>
      </section>
      <section class="thirdpiece">
        <h1>Third page</h1>
      </section>

    【讨论】:

      猜你喜欢
      • 2022-01-22
      • 2021-07-10
      • 2019-07-14
      • 1970-01-01
      • 2021-07-14
      • 1970-01-01
      • 2011-12-06
      • 2019-11-08
      • 1970-01-01
      相关资源
      最近更新 更多