--- title: Element.scrollBy() slug: Web/API/Element/scrollBy tags: - API - CSSOM View - Element - Method - Reference - scrollBy - メソッド translation_of: Web/API/Element/scrollBy --- <p>{{APIRef}}</p> <p><strong><code>scrollBy()</code></strong> は {{domxref("Element")}} インターフェイスのメソッドで、指定された量だけ要素をスクロールします。</p> <h2 id="Syntax" name="Syntax">構文</h2> <pre class="syntaxbox notranslate">element.scrollBy(<var>x-coord</var>, <var>y-coord</var>); element.scrollBy(<var>options</var>) </pre> <h3 id="Parameters" name="Parameters">引数</h3> <ul> <li><code><var>x-coord</var></code> は、スクロールしたい水平ピクセル数です。</li> <li><code><var>y-coord</var></code> は、スクロールしたい垂直ピクセル数です。</li> </ul> <p>- または -</p> <ul> <li><code><var>options</var></code> は {{domxref("ScrollToOptions")}} 辞書です。</li> </ul> <h2 id="Example" name="Example">例</h2> <pre class="brush: js notranslate">// 要素をスクロール element.scrollBy(300, 300); </pre> <p><code>options</code> を使用する場合:</p> <pre class="brush: js notranslate">element.scrollBy({ top: 100, left: 100, behavior: 'smooth' });</pre> <h2 id="Specifications" name="Specifications">仕様書</h2> <table class="standard-table"> <thead> <tr> <th scope="col">仕様書</th> <th scope="col">状態</th> <th scope="col">備考</th> </tr> </thead> <tbody> <tr> <td>{{ SpecName('CSSOM View', '#dom-element-scrollby-options-options', 'element.scrollBy()') }}</td> <td>{{ Spec2('CSSOM View') }}</td> <td>初回定義</td> </tr> </tbody> </table> <h2 id="Browser_compatibility" name="Browser_compatibility">ブラウザーの互換性</h2> <p>{{Compat("api.Element.scrollBy")}}</p>