我想要滚入一个特定行为表; div
随着 table
它里面的,两者都有 overflow:auto
. 这是我的代码滚到一个特定的索引表:
var table1 = document.getElementById("old_table");
table1.rows[3].scrollIntoView({
behavior: 'smooth',
block: 'center'
});
这是我 html:
<div id="old_slab"><table id="old_table" border="2"></table></div>
和我的 css:
#old_slab{
position: absolute;
top:34em;
left:30em;
width:40em;
height: 15em;
overflow: auto;
}
#old_table{
height: 15em;
overflow: auto;
width: 40em;
}
行在我的桌子都动态创建的,因此他们不是硬编码在我html代码。 尽管如此,该表并不空. 由于某些原因, scrollIntoView()
不我不知道为什么。 请帮助。
编辑: 奇怪的是,当我删除了 behaviour
和 block
的论点,那么它的工作:
table1.rows[3].scrollIntoView(true);