我有一个表格用户界面。我想在不滚动的情况下固定表格的位置。我怎样才能做到这一点 ? 我的表 X 溢出 enter image description here
我的代码是 https://jsfiddle.net/Divyadevi_29/1of57ouh/
我用
table {
position: relative;
padding-top: 20px;
}
table thead {
position: absolute;
left: 0;
right: 0;
top: 0;
background: #fff;
}
table thead tr {
position: fixed;
background: #fff;
}
它不工作 请帮助我。
最佳答案
对每个表格元素使用宽度(%)。试试这个 jsfiddle
table {
max-width: 100%;
border: none;
border-spacing: 0;
text-align: left;
overflow-x: hidden;
}
th, tr {
width:10%;
}
关于html - 在 X 中没有滚动的固定表格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44340916/