Element.scrollBy()
scrollBy()
は Element
インターフェイスのメソッドで、指定された量だけ要素をスクロールします。
構文
element.scrollBy(x-coord, y-coord); element.scrollBy(options)
引数
例
// 要素をスクロール
element.scrollBy(300, 300);
options
を使用する場合:
element.scrollBy({
top: 100,
left: 100,
behavior: 'smooth'
});
仕様書
Specification |
---|
CSSOM View Module # dom-element-scrollby |
ブラウザーの互換性
BCD tables only load in the browser