【问题标题】:Parallax Scrolling effect with idangerous swiper带有危险滑动器的视差滚动效果
【发布时间】:2018-04-30 17:53:01
【问题描述】:

我在 Angular 中使用了 idangerous swiper,我想达到https://www.w3schools.com/howto/howto_css_parallax.asp 中描述的效果。

我的 HTML 文件:

<div class="container">
  <swiper [config]="config">
    <img class="image" src="../assets/images/item1.jpg">
    <img class="image" src="../assets/images/item2.jpg">
  </swiper>
</div>

配置:

  config: Object = {
    autoplay: {
      delay: 10000,
      disableOnInteraction: false,
    },
    pagination: {
      el: '.swiper-pagination',
      type: 'bullets',
    },
    effect: "fade",
    speed: 2000,
  };

我还添加了教程中描述的 background-attachment 属性,但它似乎根本没有效果。

.image {
  width: 100%;
  height: 100%;
  background-attachment: fixed;
}

这个效果是不是可以实现,还是我做错了什么?

【问题讨论】:

  • 什么是'swiper'...
  • 你看过他们的演示吗? idangero.us/swiper/demos 另外,如果你创建一个 plunkr 或 stackblitz 会更容易提供帮助。

标签: html css angular swiper


【解决方案1】:

您必须在配置中启用视差。

config: Object = {
  autoplay: {
   delay: 10000,
   disableOnInteraction: false,
 },
 pagination: {
   el: '.swiper-pagination',
   type: 'bullets',
 },
 parallax: true,
 speed: 2000,
};

这里有演示:http://idangero.us/swiper/demos/360-parallax.html

【讨论】:

  • 你试过了吗?似乎与我链接的视差滚动无关。
  • 是的,你想实现垂直效果,所以你可以让你的swiper滑块垂直。你可以使用:direction: 'vertical'
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-11-18
  • 2014-05-06
  • 2017-02-14
  • 1970-01-01
  • 1970-01-01
  • 2018-05-16
相关资源
最近更新 更多