gpt4 book ai didi

javascript - 打印问题 : table scrollbars are not hidden

转载 作者:太空宇宙 更新时间:2023-11-04 01:47:22 25 4
gpt4 key购买 nike

我有一个可滚动的表格,它工作正常。然而,当我打印这个表格时,我不想出现滚动条。我包含了 CSS、表格数据填充示例和 html。

<table class="table-container">
<tbody>
<tr>
<td>Header 1</td>
<td> Header 2</td>
<td> Header 3</td>
<td> Header 4</td>
</tr>
<tr>
<td colSpan="2">
<div class="scroll-container">
<table>
<tbody id="tableBody">
</tbody>
</table>
</div>
</td>
</tr>
</tbody>
</table>

产生问题的一些数据:

for(var index=0; index< 1000; index++){
var tr= document.getElementById("tableBody").insertRow();
for(var index2=0; index2< 4; index2++){
var td= tr.insertCell();
td.innerHTML= index+ "_"+ index2;
}
}

使用的CSS样式:

.table-container {
border-radius: 3px;
width:50%;
}
.table-container table {
width: 100%;
}
.scroll-container{
max-height: 150px;
overflow-y: scroll;
}

最佳答案

Check this reference

您只需将以下内容添加到您的 CSS 中

@media print {
.scroll-container {
max-height: 100%;
overflow-y: auto;
}
}

关于javascript - 打印问题 : table scrollbars are not hidden,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44211231/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com