scroll-padding
scroll-padding
は一括指定プロパティで、要素のすべての辺にに一度にスクロールパディングを設定します。 padding
プロパティで要素のパディングを設定するのとよく似ています。
The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request.
scroll-padding-*
プロパティは、スクロールポートの最適な表示領域のオフセットを定義します。これにより、スクロールポートの中で他のコンテンツ (固定配置されたツールバーやサイドバーなど) に隠れてしまう領域を除外したり、ターゲット要素とスクロールポートの縁の間に余裕を持たせたりすることができます。
構成するプロパティ
このプロパティは以下の CSS プロパティの一括指定です。
構文
/* キーワード値 */
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;
値
<length-percentage>
- スクロールポートの対応する縁からの内側へのオフセットを、有効な
<length>
または<percentage>
として指定します。 auto
- オフセットがユーザーエージェントによって決定されます。これは一般的には
0px
になりますが、ゼロ以外の値がより適切であれば、ユーザエージェントは自由に検出して他の値を取ることができます。
公式定義
形式文法
[ auto | <length-percentage> ]{1,4}ここで
<length-percentage> = <length> | <percentage>
仕様書
仕様書 | 状態 | 備考 |
---|---|---|
CSS Scroll Snap Module Level 1 scroll-padding の定義 |
勧告候補 | 初回定義 |
ブラウザーの互換性
BCD tables only load in the browser