jquery - 整页滚动到特定部分

标签 jquery html css sass parallax

我有一个页眉、页脚和两个正文部分。我只想对我的视差容器进行整页滚动。我设法为视差设计了标记和样式,但脚本没有成功。


<div class="wrapper">
   <div class="top-content">
      <p>
         Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
      </p>
   </div>
   <div class="parallax">
      <div class="parallax__screen">
         <div class="parallax__image">
            <div class="parallax__illustration" style="background-image: url('https://picsum.photos/id/1/200/300');"></div>
         </div>
         <div class="parallax__copy">
            <p>
               Lorem Ipsum is simply dummy text of the printing and typesetting industry. 
            </p>
         </div>
      </div>
      <div class="parallax__screen">
         <div class="parallax__image">
            <div class="parallax__illustration" style="background-image: url('https://picsum.photos/id/22/200/300');"></div>
         </div>
         <div class="parallax__copy">
            <p>
               Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled
            </p>
         </div>
      </div>
      <div class="parallax__screen">
         <div class="parallax__image">
            <div class="parallax__illustration" style="background-image: url('https://picsum.photos/id/15/200/300');"></div>
         </div>
         <div class="parallax__copy">
            <p>
               it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged
            </p>
         </div>
      </div>
      <div class="parallax__screen">
         <div class="parallax__image">
            <div class="parallax__illustration" style="background-image: url('https://picsum.photos/id/10/200/300');"></div>
         </div>
         <div class="parallax__copy">
            <p>
               It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, 
            </p>
         </div>
      </div>
   </div>
   <div class="bottom-content">
      <p>
         Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
      </p>
   </div>
</div>

如有任何帮助,我们将不胜感激。这是我的 fiddle

最佳答案

您是否想避开任何图书馆并自己动手做?无论哪种方式,我认为你不能只用 CSS 来完成,你需要一些 JS。

我推荐fullPage.JS ,真的很容易使用。

关于jquery - 整页滚动到特定部分,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56343996/

相关文章:

jquery - 如何使用 jQuery 找出哪个表行被单击?

javascript - Jstree issue- 只执行一次

javascript - 使用关闭按钮取消选中复选框

Javascript onclick 函数不执行(错误日志 - 未定义)

javascript - 我可以在 sendgrid 上使用 Javascript 吗?

CSS 文件仅在某些页面上加载缓慢

javascript - 当 JSONP 数据改变时

javascript - 将页面粘贴到左下角而不是默认的左上角?

css - 当父项具有 flex-flow : column wrap; 时,元素在带有 Flexbox 的 IE11 中未水平居中

javascript - 当我重新加载页面并且没有选中 Laravel 6.0 中的单选按钮之一时,如何一次只显示一个表单