scroll-padding-bottom
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since January 2020.
scroll-padding-bottom
プロパティは、スクロールポートの最適表示領域の下のオフセットを定義します。ユーザーのビュー内でものを配置するためのターゲット領域として使用される領域です。これにより、他のコンテンツ (固定位置のツールバーやサイドバーなど) によって隠されているスクロールポートの領域を除外したり、単にターゲット要素とスクロールポートの端との間により多くの余裕を持たせたりすることができます。
試してみましょう
scroll-padding-bottom: 0;
scroll-padding-bottom: 20px;
scroll-padding-bottom: 2em;
<section class="default-example" id="default-example"> <div class="scroller" id="example-element"> <div>1</div> <div>2</div> <div>3</div> </div> <div class="info">Scroll »</div> </section>
.default-example .info { inline-size: 100%; padding: 0.5em 0; font-size: 90%; writing-mode: vertical-rl; } .scroller { text-align: left; height: 250px; width: 270px; overflow-y: scroll; display: flex; flex-direction: column; box-sizing: border-box; border: 1px solid black; scroll-snap-type: y mandatory; } .scroller > div { flex: 0 0 250px; background-color: rebeccapurple; color: #fff; font-size: 30px; display: flex; align-items: center; justify-content: center; scroll-snap-align: end; } .scroller > div:nth-child(even) { background-color: #fff; color: rebeccapurple; }
構文
css
/* キーワード値 */ scroll-padding-bottom: auto; /* <length> 値 */ scroll-padding-bottom: 10px; scroll-padding-bottom: 1em; scroll-padding-bottom: 10%; /* グローバル値 */ scroll-padding-bottom: inherit; scroll-padding-bottom: initial; scroll-padding-bottom: revert; scroll-padding-bottom: unset;
値
<length-percentage>
スクロールポートの下辺からの内側のオフセットで、有効な長さまたはパーセント値です。
auto
オフセットはユーザーエージェントが決定します。これは一般に 0px になりますが、ゼロ以外の値がもっと適切である場合をユーザーエージェントが検出して、他の値を採用することもできます。
公式定義
初期値 | auto |
---|---|
適用対象 | スクロールコンテナー |
継承 | なし |
パーセント値 | スクロールコンテナーのスクロールポートに対する相対値 |
計算値 | 指定通り |
アニメーションの種類 | 計算値の型による |
形式文法
scroll-padding-bottom =
auto|
<length-percentage [0,∞]>
<length-percentage> =
<length>|
<percentage>
仕様書
Specification |
---|
CSS Scroll Snap Module Level 1 # padding-longhands-physical |