scroll-snap-type 实现上拉加载

Posted 前端精髓

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了scroll-snap-type 实现上拉加载相关的知识,希望对你有一定的参考价值。

<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    * {
      margin: 0;
      padding: 0;
    }
    html, body {
      width: 100%;
      height: 100%;
    }

    .example-wrapper {
      width: 100%;
      height: 100%;
    }

    .container {
      width: 100%;
      height: 100%;
      overflow: auto;
    }

    .item {
      width: 300px;
      scroll-snap-align: start;
      font-size: 50px;
      justify-content: center;
      align-items: center;
    }

    .both-mandatory {
      scroll-snap-type: y mandatory;
    }

    .wrapper {
      width: 100%;
      height: 100%;
      padding: 50px 0;
      position: relative;
    }

    .padding-0px {
      scroll-padding: 0px 0px 0px 0px;
    }

    .more {
      position: absolute;
      left: 0;
      top: 0;
      text-align: center;
    }
  </style>

</head>

<body>
  <div class="example-wrapper">
    <div class="container both-mandatory padding-0px">
      <div class="wrapper">
        <div class="more">加载更多</div>
        <ul class="element">
          <li class="item">1</li>
          <li class="item">1</li>
          <li class="item">1</li>
          <li class="item">1</li>
          <li class="item">1</li>
          <li class="item">1</li>
          <li class="item">1</li>
          <li class="item">1</li>
          <li class="item">1</li>
          <li class="item">1</li>
          <li class="item">1</li>
          <li class="item">1</li>
          <li class="item">1</li>
          <li class="item">1</li>
          <li class="item">1</li>
          <li class="item">1</li>
          <li class="item">1</li>
          <li class="item">1</li>
          <li class="item">1</li>
          <li class="item">1</li>
          <li class="item">1</li>
        </ul>
      </div>
    </div>

  </div>
</body>

</html>

以上是关于scroll-snap-type 实现上拉加载的主要内容,如果未能解决你的问题,请参考以下文章

原生js实现上拉加载

JQuery代码实现上拉加载

免插件,简单实现上拉加载loading

Android 使用SwipeRefreshLayout实现RecyclerVeiw的下拉刷新和上拉加载

jsp手机端网页实现下拉刷新,上拉加载

ListView上拉加载和下拉刷新多种实现方式