可以通过CSS中的定位属性position来解决该问题。将页脚的position属性设置为fixed,同时给表格的父容器设置一个margin-bottom来确保表格不会完全覆盖页脚。示例代码如下:
HTML:
表头1
表头2
表头3
单元格1
单元格2
单元格3
CSS:
footer {
position: fixed;
bottom: 0;
width: 100%;
height: 50px; /* 设置页脚高度 */
background-color: #ccc;
}
.tableContainer {
margin-bottom: 50px; /* 与页脚高度相同 */
}
table {
width: 100%;
border-collapse: collapse;
}
th, td {
border: 1px solid #ccc;
padding: 8px;
text-align: left;
}
下一篇:表格小部件不显示