css - 如何使集合标题保持在顶部并使集合项可滚动?

标签 css meteor materialize

我在 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

最佳答案

如果您将 collection 列表的 max-height 设置为允许列表滚动的特定值。将第一个 collection-itemposition 设置为 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;
}

关于css - 如何使集合标题保持在顶部并使集合项可滚动?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42267664/

相关文章:

javascript - 如何从 Materialise 的开关中获取值?

javascript - 单击 Materialize-css React 按钮内的图标会触发 onClick

css - 根据 body 类别覆盖 Bootstrap 4 中的原色?

表列中的 CSS (td) : Align right in but move to the left with padding

meteor - 我可以在 meteor 中使用 autoform & collection2 包以一种形式使用两个不同的集合吗?

javascript - 在 Materialise v1.0.0 中使用 React.JS 无法初始化 JS

html - CSS 定位图像以随窗口调整大小

html - 并排放置 div 会导致换行,而不是溢出

css - 无法在我的 Meteor 应用程序上呈现样式表(MIME 错误)

ruby-on-rails - 如果我不需要实时功能,为什么要使用 Node.js?