可滚动div内的内容,导致IE中的页面滚动条

时间:2018-05-28 22:32:08

标签: html css internet-explorer html-table internet-explorer-11

我正在尝试将粘性标头合并到我公司的内部数据表组件中。我使用它的最佳方式(使用Chrome),而不是搞砸任何其他功能就是产生这样的东西:

<table class="headers">
    <thead> // ... header stuff</thead>
    <tbody> // ... body stuff</tbody>
</table>
<div class="scrollBody">
    <table class="headers">
        <thead> // ... header stuff</thead>
        <tbody> // ... body stuff</tbody>
    </table>
</table>

和css一样:

th {
    border: 1px solid black;
}
.headers tbody {
    visibility: collapse;
}
.scrollBody thead {
    visibility: collapse;
}
.scrollBody {
    display: inline-block;
    max-height: 250px;
    overflow: auto;
}

这在Chrome中完全符合要求。它显示一个带有标题的表格和一个滚动表格主体的滚动条。但是,在IE中,它看起来是正确的,直到您意识到该页面现在有2个滚动条。表体旁边(正如预期的那样),页面本身就有一个。

以下是codepen的链接:https://codepen.io/petetalksweb2/pen/WyeaWL?editors=1100

感谢任何帮助。

1 个答案:

答案 0 :(得分:1)

使用div overflow: hidden;

围绕它

CodePen