javascript - 为什么我的数据表固定标题不起作用/
问题描述
我正在尝试使我的数据表 Thead 成为一个粘性表,但是当我尝试使用固定标题时,它就不起作用了。我已经尝试position: fixed; , top: 0;
并尝试使用 css 修复它,但是当完成此操作时,它在 firefox 中按预期工作,但在 crome edge opera 中无法按预期工作。
"stateSave": false,
"orderCellsTop": true,
"fixedHeader": {
header: true,
},
"columns": [
{'data':'chk_select_header','orderable': false},
这是我的 ajax 代码。
解决方案
我曾试图在我的数据表中修复我的thead。但是这个数据表将该广告固定到该页面的顶部,例如https://datatables.net/extensions/fixedheader/examples/options/simple.html但我想坚持该数据表 div 。我发现唯一的方法是使用下面的 CSS 方法
thead tr:first-child Th {
position: sticky;
z-index: 12;
top: 0;
background: white;
}
thead Th {
position: sticky;
z-index: 12;
top: 51px;
background: white;
}
这是将数据表头粘贴到表头的最简单方法
推荐阅读
- c++ - 向 std::map 或 std::unordered_map 插入太多项目时的奇怪行为
- facebook-graph-api - Instagram Basic API:是否可以在一次查询中从“CAROUSEL_ALBUM”获取 media_url?
- websocket - 使用带有树莓派 3b+ 的 websocket/webRTC 将实时视频从本地 IP 流式传输到外部网络中的浏览器
- typescript - 为什么是承诺
在可达性分析中没有考虑? - react-native - SyntaxError:在 const 声明 React-Native 中缺少初始化程序
- python - 为什么我会收到矩阵的属性错误 __enter__?
- r - 如何防止 as.data.frame.matrix 使用我的第一个变量作为行名?
- java - 无法用简单的儿子解析 JSON 数组
- node.js - 我正在尝试在 Express 中路由 pug 文件。不是从视图文件夹中呈现的页面
- kubernetes - 带有 GPU 的 GCP kubernetes 节点过早被抢占