Element: scrollBy() メソッド
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since September 2020.
scrollBy()
は Element
インターフェイスのメソッドで、指定された量だけ要素をスクロールします。
構文
js
scrollBy(x-coord, y-coord)
scrollBy(options)
引数
返値
なし (undefined
)。
例
js
// 要素をスクロール
element.scrollBy(300, 300);
options
を使用する場合:
js
element.scrollBy({
top: 100,
left: 100,
behavior: "smooth",
});
仕様書
Specification |
---|
CSSOM View Module # dom-element-scrollby |
ブラウザーの互換性
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
scrollBy | ||||||||||||
options.behavior parameter | ||||||||||||
options.left parameter | ||||||||||||
options.top parameter |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
The compatibility table on 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.