如何在单击时切换 Slick 滑块(向下滑动并向上滑动)

科里·布什

我正在努力在一些 Slick 滑块上获得平滑的向下滑动动画。

我需要滑块和“项目”按钮在单击上述标题时以向下滑动的方式设置动画。

我有它,滑块/按钮容器在点击时会向下滑动(切换一个改变容器最大高度的类),但滑块和按钮只是弹出视图并且不会与容器一起向下动画。

代码笔链接:https ://codepen.io/Finches/pen/jYrzWv

在这里获得平滑的下滑过渡有什么帮助吗?代码片段...

.service-content-wrapper {
  margin: 0 auto;
  width: 100%;
  visibility: hidden;
  margin-bottom: 25px;
  max-height: 0;
  transition: max-height 2s;
}

.accordion-content-wrapper {
  background: blue;
}

.active {
  max-height: 1000px;
  visibility: visible;
}

——

$('.title-box').click(function() {
  $(this).siblings('.service-content-wrapper').toggleClass('active');
});
重生

如果您想在不使用的@keyframes情况下通过 css 为高度设置动画,您可能需要更改一些内容,看看下面是否是您想要的幻灯片显示方式,请尝试全屏查看。

$('.accordion-content-wrapper').slick({
  prevArrow: false
});

$('.title-box').click(function() {
  $(this).siblings('.service-content-wrapper').toggleClass('active');
});
body {
  font-family: 'Open Sans', sans-serif;
}

.title-box h1 {
  margin: 0 auto;
  text-align: center;
  padding: 25px;
}

.service-content-wrapper {
  margin: 0 auto;
  width: 100%;
  /*   margin-bottom: 25px; */
  height: 0px;
  position: relative;
  transition: 1s;
}

.accordion-content-wrapper {
  background: blue;
}

.active {
  transition: 1s;
  height: 350px;
}

.slide-1,
.slide-2 {
  width: 100%;
}

.slick-next {
  position: absolute;
  bottom: 10px;
  right: 10px;
}

.title-box {
  background: gray;
  width: 100%;
  z-index: 9999 !important;
  position: relative;
}

.service-container {
  /*   background: pink; */
  margin: 10px;
  overflow: hidden;
  position: relative;
}

.page-container {
  padding: 25px;
}

.btn {
  padding: 15px;
  background: salmon;
  text-align: center;
  text-transform: uppercase;
  font-weight: 900;
  margin-top: 15px;
  margin-bottom: 15px;
}

.btn:hover {
  background: red;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/flexboxgrid/6.3.1/flexboxgrid.css" rel="stylesheet" />
<link href="https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.8.1/slick.min.css" rel="stylesheet" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.8.1/slick.min.js"></script>
<div class="row page-container">

  <div class="col-md-4 col-xs-12 services-column">

    <div class="service-container">

      <div class="title-box col-md-12">
        <h1>HEAVY CIVIL</h1>
      </div>

      <div class="service-content-wrapper">

        <div class="accordion-content-wrapper col-md-12">

          <div class="slide-1 col-md-12">
            This is test content.
          </div>
          <!-- slide-1 -->

          <div class="slide-2 col-md-12">
            <p>It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content
              here, content here', making it look like readable English.</p>
            <p> Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes
              by accident, sometimes on purpose (injected humour and the like).</p>
          </div>
          <!-- slide-2 -->

        </div>
        <!-- accordion-content-wrapper -->

        <div class="btn col-md-12">PROJECTS</div>

      </div>
      <!-- service-content-wrapper -->

    </div>
    <!-- service-container -->

    <div class="service-container">

      <div class="title-box col-md-12">
        <h1>HEAVY CIVIL</h1>
      </div>

      <div class="service-content-wrapper">

        <div class="accordion-content-wrapper col-md-12">

          <div class="slide-1 col-md-12">
            This is test content.
          </div>
          <!-- slide-1 -->

          <div class="slide-2 col-md-12">
            <p>It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content
              here, content here', making it look like readable English.</p>
            <p> Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes
              by accident, sometimes on purpose (injected humour and the like).</p>
          </div>
          <!-- slide-2 -->

        </div>
        <!-- accordion-content-wrapper -->

        <div class="btn col-md-12">PROJECTS</div>

      </div>
      <!-- service-content-wrapper -->

    </div>
    <!-- service-container -->

  </div>
  <!-- col-md-4 -->

  <div class="col-md-4 col-xs-12 services-column">

    <div class="service-container">

      <div class="title-box col-md-12">
        <h1>HEAVY CIVIL</h1>
      </div>

      <div class="service-content-wrapper">

        <div class="accordion-content-wrapper col-md-12">

          <div class="slide-1 col-md-12">
            This is test content.
          </div>
          <!-- slide-1 -->

          <div class="slide-2 col-md-12">
            <p>It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content
              here, content here', making it look like readable English.</p>
            <p> Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes
              by accident, sometimes on purpose (injected humour and the like).</p>
          </div>
          <!-- slide-2 -->

        </div>
        <!-- accordion-content-wrapper -->

        <div class="btn col-md-12">PROJECTS</div>

      </div>
      <!-- service-content-wrapper -->

    </div>
    <!-- service-container -->

    <div class="service-container">

      <div class="title-box col-md-12">
        <h1>HEAVY CIVIL</h1>
      </div>

      <div class="service-content-wrapper">

        <div class="accordion-content-wrapper col-md-12">

          <div class="slide-1 col-md-12">
            This is test content.
          </div>
          <!-- slide-1 -->

          <div class="slide-2 col-md-12">
            <p>It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content
              here, content here', making it look like readable English.</p>
            <p> Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes
              by accident, sometimes on purpose (injected humour and the like).</p>
          </div>
          <!-- slide-2 -->

        </div>
        <!-- accordion-content-wrapper -->

        <div class="btn col-md-12">PROJECTS</div>

      </div>
      <!-- service-content-wrapper -->

    </div>
    <!-- service-container -->

  </div>
  <!-- col-md-4 -->

  <div class="col-md-4 col-xs-12 services-column">

    <div class="service-container">

      <div class="title-box col-md-12">
        <h1>HEAVY CIVIL</h1>
      </div>

      <div class="service-content-wrapper">

        <div class="accordion-content-wrapper col-md-12">

          <div class="slide-1 col-md-12">
            This is test content.
          </div>
          <!-- slide-1 -->

          <div class="slide-2 col-md-12">
            <p>It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content
              here, content here', making it look like readable English.</p>
            <p> Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes
              by accident, sometimes on purpose (injected humour and the like).</p>
          </div>
          <!-- slide-2 -->

        </div>
        <!-- accordion-content-wrapper -->

        <div class="btn col-md-12">PROJECTS</div>

      </div>
      <!-- service-content-wrapper -->

    </div>
    <!-- service-container -->

    <div class="service-container">

      <div class="title-box col-md-12">
        <h1>HEAVY CIVIL</h1>
      </div>

      <div class="service-content-wrapper">

        <div class="accordion-content-wrapper col-md-12">

          <div class="slide-1 col-md-12">
            This is test content.
          </div>
          <!-- slide-1 -->

          <div class="slide-2 col-md-12">
            <p>It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content
              here, content here', making it look like readable English.</p>
            <p> Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes
              by accident, sometimes on purpose (injected humour and the like).</p>
          </div>
          <!-- slide-2 -->

        </div>
        <!-- accordion-content-wrapper -->

        <div class="btn col-md-12">PROJECTS</div>

      </div>
      <!-- service-content-wrapper -->

    </div>
    <!-- service-container -->

  </div>
  <!-- col-md-4 -->

</div>
<!-- row -->

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

jQuery向上滑动和向下滑动切换

来自分类Dev

如何创建向上/向下滑动的 UITableView?

来自分类Dev

在不活动时滚动向下滑动并向下滑动

来自分类Dev

通过向上/向下滑动切换到片段

来自分类Dev

当您单击链接时,向上和向下滑动

来自分类Dev

粘性标头在向上滚动时向下滑动

来自分类Dev

当单击标题时,当新列表向下滑动时,jQuery向上滑动显示列表?

来自分类Dev

如何在单击按钮时向上/向下滑动隐藏的div?

来自分类Dev

如何在单击按钮时向上/向下滑动隐藏的div?

来自分类Dev

jQuery单击时向下滑动

来自分类Dev

单击按钮后,追加表单,向下滑动并在第二次单击时向上滑动

来自分类Dev

单击按钮后,追加表单,向下滑动并在第二次单击时向上滑动

来自分类Dev

如何在 viewPager 上添加向上/向下滑动检测?

来自分类Dev

向下滑动时,CalendarView关闭

来自分类Dev

向下滑动时,CalendarView会关闭

来自分类Dev

如何获得位图在视图顶部向下滑动,停留一会儿然后向上滑动?

来自分类Dev

如何向下滑动图像视图?

来自分类Dev

如何仅向下滑动当前元素

来自分类Dev

Android:如何使swipeRefreshLayout难以向下滑动

来自分类Dev

如何使元素从display:none向下滑动?

来自分类Dev

动画化固定标头以在单击时向下滑动

来自分类Dev

AngularJS-单击时向下滑动菜单

来自分类Dev

单击时,向下滑动div并更改按钮图标

来自分类Dev

jQuery 向下滑动 div - 单击回调时消失

来自分类Dev

如何使导航栏项目在悬停时向下滑动?(jQuery的)

来自分类Dev

如何在SwipeRefreshLayout中调整向下滑动距离?

来自分类Dev

如何在悬停文本中向下滑动图像

来自分类Dev

向下滑动和向上滑动

来自分类Dev

向下滑动和向上滑动

Related 相关文章

  1. 1

    jQuery向上滑动和向下滑动切换

  2. 2

    如何创建向上/向下滑动的 UITableView?

  3. 3

    在不活动时滚动向下滑动并向下滑动

  4. 4

    通过向上/向下滑动切换到片段

  5. 5

    当您单击链接时,向上和向下滑动

  6. 6

    粘性标头在向上滚动时向下滑动

  7. 7

    当单击标题时,当新列表向下滑动时,jQuery向上滑动显示列表?

  8. 8

    如何在单击按钮时向上/向下滑动隐藏的div?

  9. 9

    如何在单击按钮时向上/向下滑动隐藏的div?

  10. 10

    jQuery单击时向下滑动

  11. 11

    单击按钮后,追加表单,向下滑动并在第二次单击时向上滑动

  12. 12

    单击按钮后,追加表单,向下滑动并在第二次单击时向上滑动

  13. 13

    如何在 viewPager 上添加向上/向下滑动检测?

  14. 14

    向下滑动时,CalendarView关闭

  15. 15

    向下滑动时,CalendarView会关闭

  16. 16

    如何获得位图在视图顶部向下滑动,停留一会儿然后向上滑动?

  17. 17

    如何向下滑动图像视图?

  18. 18

    如何仅向下滑动当前元素

  19. 19

    Android:如何使swipeRefreshLayout难以向下滑动

  20. 20

    如何使元素从display:none向下滑动?

  21. 21

    动画化固定标头以在单击时向下滑动

  22. 22

    AngularJS-单击时向下滑动菜单

  23. 23

    单击时,向下滑动div并更改按钮图标

  24. 24

    jQuery 向下滑动 div - 单击回调时消失

  25. 25

    如何使导航栏项目在悬停时向下滑动?(jQuery的)

  26. 26

    如何在SwipeRefreshLayout中调整向下滑动距离?

  27. 27

    如何在悬停文本中向下滑动图像

  28. 28

    向下滑动和向上滑动

  29. 29

    向下滑动和向上滑动

热门标签

归档