问题描述: 当使用Ajax调用获取表格行数据时,表头与表行不对齐。
解决方法:
table {
table-layout: fixed;
}
td {
width: 100px; /* 设置固定宽度,根据实际情况调整 */
}
table {
display: table;
width: 100%;
border-collapse: collapse;
table-layout: fixed;
}
thead, tbody, tr, td {
display: table-row;
}
表头1
表头2
表头3
.table-wrapper {
height: 200px; /* 设置表格高度,根据实际情况调整 */
overflow-y: scroll;
}
table {
width: 100%;
}
thead, tbody {
display: block;
}
tbody {
height: 100%;
overflow-y: scroll;
}
以上是一些解决表头与由Ajax调用的表行不对齐的方法,根据实际情况选择适合的方式解决问题。
上一篇:表头与sticky属性不兼容。
下一篇:表头在请求时不排序