调整页面大小时如何获取滚动条?



我有一个简单的网页,上面有一个表格。我也添加了固定属性和溢出属性,但表格总是在页面底部显示为"切断"。我正在尝试在页面上获取滚动条,以便当表格行不适合(例如用户调整窗口大小(时,用户应该能够向下滚动到最后一行。

#dstable {
table-layout:fixed;
font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
border-collapse: collapse;
width: 90%;
height: 90%;
overflow: scroll;
}
#dstable td {
border: 1px solid white;
height: 100px;
width: 300px;
font-size: 18px;
color: black;
padding: 15px;
text-align: right;
}
#dstable tr:nth-child(even) {
background-color: white;
}
#dstable tr:nth-child(odd) {
background-color: #e0f7d0;
}
#dstable td:hover {
background-color: #ddd;
}
#dstable th {
padding: 8px;
padding-top: 12px;
padding-bottom: 12px;
text-align: center;
background-color: #4CAF50;
color: white;
}

尝试将max-height: 90%;添加到#dstable中,这应该可以解决问题。

最新更新