Javascript .scrollIntoView(boolean)
只提供两个对齐选项。
- 顶
- 底部
如果我想这样 ScrollView 怎么办。我想将特定元素放在页面中间的某处?
最佳答案
试试这个:
document.getElementById('myID').scrollIntoView({
behavior: 'auto',
block: 'center',
inline: 'center'
});
有关更多信息和选项,请参阅此处:https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView
关于Javascript scrollIntoView() 中间对齐?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8922107/