reactjs - 使用 Reactstrap 响应表的具有固定标题的可滚动表

标签 reactjs reactstrap

我有这张表 https://stackblitz.com/edit/reactstrap-v8-pwyocr?file=Example.js 在我的一个项目中实现只是想要的是可以使标题保持不变并且只使表体移动 (像这样的东西:https://v4.mui.com/components/tables/#fixed-header)

谁能帮我解决这个问题

最佳答案

为标题单元格使用粘性位置,并确保使用 z-index 和背景可以在正文单元格上方看到它们

react :

...
<Table height="200" bordered className="fixed-header">
...

CSS:

.fixed-header thead th { /* the thead selector is required because there are th elements in the body */
  position: sticky;
  top: 0;
  z-index: 10;
  background-color: white;
}

注意:该解决方案可能会导致页眉边框出现问题 - 它们不会在滚动中显示。这个问题建议了该问题的可能解决方案: Table headers position:sticky and border issue

关于reactjs - 使用 Reactstrap 响应表的具有固定标题的可滚动表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69812993/

相关文章:

reactjs - Reactstrap - create-react-app - 未找到 bootstrap/dist/css/bootstrap.css - v.4

javascript - 在悬停reactjs上显示菜单

reactjs - React在多个Reactstrap按钮之间切换事件类

javascript - 比较2个对象数组中的值并创建新数组,js

javascript - React NextJS 的映射对象 JSX 内的 onClick 不起作用

reactjs - 为 Next Js 项目 React Helm 还是 next/head?

reactjs - Reactstrap 中的标签属性有什么作用?

reactjs - Reactstrap DropdownMenu底部溢出问题

javascript - 如何在 React 中动态分配属性?

javascript - 如何使用 React/JSX 显示不同的时间?