scrollBy()
方法是使得元素滚动一段特定距离的 Element
接口。
Syntax
element.scrollBy(x-coord, y-coord); element.scrollBy(options)
Parameters
例子
// 让元素滚动
element.scrollBy(300, 300);
使用 options
:
element.scrollBy({
top: 100,
left: 100,
behavior: 'smooth'
});
规范
规范 | 状态 | 注释 |
---|---|---|
CSS Object Model (CSSOM) View Module element.scrollBy() |
Working Draft | Initial definition. |
浏览器兼容性
BCD tables only load in the browser
The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.