我正在做一个项目,其中我的代码结构为 -
<div id="scroll" class="datagrid" style="position: relative">
<table id="datatable" class="datatable">
<thead id="header" class="header">
<tr>
....
</tr>
<tbody id="content">
<tr>
....
</tr>
</tbody>
对于 thead 中的 tr,我们的表达式为 -
.header tr
{
top: expression(document.getElementById('datagrid').scrollTop);
}
在 IE8 中,这个表达式被求值并且顶部被设置,这样标题总是可见的。然而,由于表达式在 IE11 中不起作用,因此我们可以为此编写一个 JavaScript 函数。
但是在 IE11 中,top 属性不能按预期工作。即使在应用之后,标题也是不可见的。
有人可以建议可能出了什么问题吗?
PS:我尝试的 Javascript 是:
document.getElementById("header").getElementsByTagName('tr')[0].style.top = document.getElementById('scroll').scrollTop ;