--- title: scroll-padding slug: Web/CSS/scroll-padding tags: - CSS - CSS Property - 'recipe:css-shorthand-property' - scroll-snap translation_of: Web/CSS/scroll-padding --- <div>{{CSSRef}}</div> <p><strong><code>scroll-padding</code></strong> は<a href="/ja/docs/Web/CSS/Shorthand_properties">一括指定プロパティ</a>で、要素のすべての辺にに一度にスクロールパディングを設定します。 {{cssxref("padding")}} プロパティで要素のパディングを設定するのとよく似ています。</p> <div>{{EmbedInteractiveExample("pages/css/scroll-padding.html")}}</div> <div class="hidden">このデモのソースファイルは GitHub リポジトリに格納されています。デモプロジェクトに協力したい場合は、 <a href="https://github.com/mdn/interactive-examples">https://github.com/mdn/interactive-examples</a> をクローンしてプルリクエストを送信してください。</div> <p><code>scroll-padding-*</code> プロパティは、スクロールポートの<dfn>最適な表示領域</dfn>のオフセットを定義します。これにより、スクロールポートの中で他のコンテンツ (固定配置されたツールバーやサイドバーなど) に隠れてしまう領域を除外したり、ターゲット要素とスクロールポートの縁の間に余裕を持たせたりすることができます。</p> <h2 id="Constituent_properties" name="Constituent_properties">構成するプロパティ</h2> <p>このプロパティは以下の CSS プロパティの一括指定です。</p> <ul> <li>{{cssxref("scroll-padding-bottom")}}</li> <li>{{cssxref("scroll-padding-left")}}</li> <li>{{cssxref("scroll-padding-right")}}</li> <li>{{cssxref("scroll-padding-top")}}</li> </ul> <h2 id="Syntax" name="Syntax">構文</h2> <pre class="brush: css notranslate">/* キーワード値 */ scroll-padding: auto; /* <length> 値 */ scroll-padding: 10px; scroll-padding: 1em .5em 1em 1em; scroll-padding: 10%; /* グローバル値 */ scroll-padding: inherit; scroll-padding: initial; scroll-padding: unset; </pre> <h3 id="Values" name="Values">値</h3> <dl> <dt>{{cssxref("<length-percentage>")}}</dt> <dd>スクロールポートの対応する縁からの内側へのオフセットを、有効な {{cssxref("<length>")}} または {{cssxref("<percentage>")}} として指定します。</dd> <dt><code>auto</code></dt> <dd>オフセットがユーザーエージェントによって決定されます。これは一般的には <code>0px</code> になりますが、ゼロ以外の値がより適切であれば、ユーザエージェントは自由に検出して他の値を取ることができます。</dd> </dl> <h2 id="Formal_definition" name="Formal_definition">公式定義</h2> <p>{{CSSInfo}}</p> <h2 id="Formal_syntax" name="Formal_syntax">形式文法</h2> {{csssyntax}} <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("CSS Scroll Snap Points", "#propdef-scroll-padding", "scroll-padding")}}</td> <td>{{Spec2("CSS Scroll Snap Points")}}</td> <td>初回定義</td> </tr> </tbody> </table> <h2 id="Browser_compatibility" name="Browser_compatibility">ブラウザーの互換性</h2> <p>{{Compat("css.properties.scroll-padding")}}</p>