1. 開発者向けのウェブ技術
  2. CSS: カスケーディングスタイルシート
  3. scroll-padding-inline-start

このページはコミュニティーの尽力で英語から翻訳されました。MDN Web Docs コミュニティーについてもっと知り、仲間になるにはこちらから。

View in English Always switch to English

scroll-padding-inline-start

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since ⁨2021年9月⁩.

scroll-padding-inline-start プロパティは、スクロールポートの最適表示領域のインライン方向における先頭側のオフセットを定義します。ユーザーのビュー内でものを配置するためのターゲット領域として使用される領域です。これにより、他のコンテンツ(固定位置のツールバーやサイドバーなど)によって隠されているスクロールポートの領域を除外したり、単にターゲット要素とスクロールポートの端との間により多くの余裕を持たせたりすることができます。

試してみましょう

scroll-padding-inline-start: 0;
scroll-padding-inline-start: 20px;
scroll-padding-inline-start: 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">スクロール »</div>
</section>
.default-example {
 flex-wrap: wrap;
}
.default-example .info {
 width: 100%;
 padding: 0.5em 0;
 font-size: 90%;
}
.scroller {
 text-align: left;
 width: 250px;
 height: 250px;
 overflow-x: scroll;
 display: flex;
 box-sizing: border-box;
 border: 1px solid black;
 scroll-snap-type: x mandatory;
}
.scroller > div {
 flex: 0 0 250px;
 width: 250px;
 background-color: rebeccapurple;
 color: #fff;
 font-size: 30px;
 display: flex;
 align-items: center;
 justify-content: center;
 scroll-snap-align: start;
}
.scroller > div:nth-child(even) {
 background-color: #fff;
 color: rebeccapurple;
}

構文

css
/* キーワード値 */
scroll-padding-inline-start: auto;
/* <length> 値 */
scroll-padding-inline-start: 10px;
scroll-padding-inline-start: 1em;
scroll-padding-inline-start: 10%;
/* グローバル値 */
scroll-padding-inline-start: inherit;
scroll-padding-inline-start: initial;
scroll-padding-inline-start: revert;
scroll-padding-inline-start: revert-layer;
scroll-padding-inline-start: unset;

<length-percentage>

スクロールポートのインライン方向の先頭側からの内側のオフセットで、有効な長さまたはパーセント値です。

auto

オフセットはユーザーエージェントが決定します。これは一般に 0px になりますが、ゼロ以外の値がもっと適切である場合をユーザーエージェントが検出して、他の値を採用することもできます。

公式定義

初期値 auto
適用対象スクロールコンテナー
継承 なし
パーセント値スクロールコンテナーのスクロールポートに対する相対値
計算値 指定通り
アニメーションの種類 計算値の型による

形式文法

scroll-padding-inline-start = 
auto |
<length-percentage [0,∞]>

<length-percentage> =
<length> |
<percentage>

仕様書

Specification
CSS Scroll Snap Module Level 1
# padding-longhands-logical

ブラウザーの互換性

関連情報

Help improve MDN

Learn how to contribute

This page was last modified on by MDN contributors.

AltStyle によって変換されたページ (->オリジナル) /