【问题标题】:How to make collection header stay on top and collection items scrollable?如何使集合标题保持在顶部并且集合项可滚动?
【发布时间】:2017-07-05 04:38:14
【问题描述】:

我在 SPA 中的一个布局中有导航栏、过滤器和集合 - 完全按照该顺序。导航栏、过滤器和集合标题在滚动时必须保持在顶部,只有集合项必须是可滚动的。我设法使整个集合可滚动,但这并不是我想要的。

<div class="navbar-fixed">
  <nav>...</nav>
</div>
<div class="row">...this is filter...</div>
<div id="collection-wrapper">
  <ul class="collection">
    <li class="collection-item"></li> <!-- serves as header --> 
    <li class="collection-item"></li> <!-- shows data -->
  </ul>
</div>

在#collection-wrapper 上使用完美滚动条:https://github.com/noraesae/perfect-scrollbar

【问题讨论】:

    标签: css meteor materialize


    【解决方案1】:

    如果您将collection 列表的max-height 设置为允许列表滚动的特定值。将第一个 collection-item 的 position 设置为 fixed 将阻止该项目与列表的其余部分一起滚动。

    ul.collection {
      max-height: 100px;
      overflow: scroll;
      list-style-type: none; /* not sure if you need this. Hides bullet list dots */
    }
    
    li.collection-item:first-child {
      background-color: white; /* should be the same as the background color behind the list */
      position: fixed;
    }
    

    【讨论】:

    • 必须调整第一个集合项的宽度和顶部属性以使标题融入其中,但基本上就是这样。谢谢。
    猜你喜欢
    • 1970-01-01
    • 2023-04-04
    • 2021-09-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-12-19
    • 2020-07-21
    相关资源
    最近更新 更多