スクロール留めの規則。
名前 | scroll-snap-type
|
---|---|
値 | none | [x | y | block | inline | both] [mandatory | proximity]? |
初期値 | none |
適用対象 | すべての要素 |
継承 | されない |
百分率 | 受容しない |
算出値 | 指定されたキーワード(たち) |
正準的順序 | 文法に従う |
アニメーション型 | 離散的 |
scroll-snap-type プロパティは、スクロール コンテナはスクロール留めコンテナになるかどうか、および[そうであれば、どの軸が考慮され、どの程度厳密に留められるべきか]を指定する。厳密度値は、指定されていない場合は proximity と見なされる。
¶例省く
ユーザー エージェントは、根要素に設定された scroll-snap-type 値を文書表示域に適用するものとする。(overflow プロパティと違って、scroll-snap-type 値は、HTML BODY要素からは伝播しないことに注意。)
none
<DIV style="border:1px solid red; width:100px; height:100px; box-sizing:content-box; display:flex; overflow-x:scroll; scroll-snap-type:none; "> <DIV style="border:1px solid black; box-sizing:border-box; font-size:30px; flex:0 0 100px; width:100px; display:flex; align-items:center; justify-content:center; scroll-snap-align:start; ">1</DIV> <DIV style="border:1px solid black; box-sizing:border-box; font-size:30px; flex:0 0 100px; width:100px; display:flex; align-items:center; justify-content:center; scroll-snap-align:start; ">2</DIV> <DIV style="border:1px solid black; box-sizing:border-box; font-size:30px; flex:0 0 100px; width:100px; display:flex; align-items:center; justify-content:center; scroll-snap-align:start; ">3</DIV> <DIV style="border:1px solid black; box-sizing:border-box; font-size:30px; flex:0 0 100px; width:100px; display:flex; align-items:center; justify-content:center; scroll-snap-align:start; ">4</DIV> </DIV>
x
、y
<DIV style="border:1px solid red; width:100px; height:100px; box-sizing:content-box; display:flex; overflow-x:scroll; scroll-snap-type:x; "> <DIV style="border:1px solid black; box-sizing:border-box; font-size:30px; flex:0 0 100px; width:100px; display:flex; align-items:center; justify-content:center; scroll-snap-align:start; ">1</DIV> <DIV style="border:1px solid black; box-sizing:border-box; font-size:30px; flex:0 0 100px; width:100px; display:flex; align-items:center; justify-content:center; scroll-snap-align:start; ">2</DIV> <DIV style="border:1px solid black; box-sizing:border-box; font-size:30px; flex:0 0 100px; width:100px; display:flex; align-items:center; justify-content:center; scroll-snap-align:start; ">3</DIV> <DIV style="border:1px solid black; box-sizing:border-box; font-size:30px; flex:0 0 100px; width:100px; display:flex; align-items:center; justify-content:center; scroll-snap-align:start; ">4</DIV> </DIV>
block
、inline
<DIV style="border:1px solid red; width:100px; height:100px; box-sizing:content-box; display:flex; overflow-x:scroll; scroll-snap-type:inline; "> <DIV style="border:1px solid black; box-sizing:border-box; font-size:30px; flex:0 0 100px; width:100px; display:flex; align-items:center; justify-content:center; scroll-snap-align:start; ">1</DIV> <DIV style="border:1px solid black; box-sizing:border-box; font-size:30px; flex:0 0 100px; width:100px; display:flex; align-items:center; justify-content:center; scroll-snap-align:start; ">2</DIV> <DIV style="border:1px solid black; box-sizing:border-box; font-size:30px; flex:0 0 100px; width:100px; display:flex; align-items:center; justify-content:center; scroll-snap-align:start; ">3</DIV> <DIV style="border:1px solid black; box-sizing:border-box; font-size:30px; flex:0 0 100px; width:100px; display:flex; align-items:center; justify-content:center; scroll-snap-align:start; ">4</DIV> </DIV>
both
<DIV style="border:1px solid red; width:100px; height:100px; font-size:30px; box-sizing:content-box; overflow:auto; display:grid; grid-template:'a a a' 70px 'a a a' 70px 'a a a' 70px/70px 70px 70px; scroll-snap-type:both; "> <DIV style="border:1px solid black; box-sizing:border-box; display:flex; align-items:center; justify-content:center; scroll-snap-align:center; ">1</DIV> <DIV style="border:1px solid black; box-sizing:border-box; display:flex; align-items:center; justify-content:center; scroll-snap-align:center; ">2</DIV> <DIV style="border:1px solid black; box-sizing:border-box; display:flex; align-items:center; justify-content:center; scroll-snap-align:center; ">3</DIV> <DIV style="border:1px solid black; box-sizing:border-box; display:flex; align-items:center; justify-content:center; scroll-snap-align:center; ">4</DIV> <DIV style="border:1px solid black; box-sizing:border-box; display:flex; align-items:center; justify-content:center; scroll-snap-align:center; ">5</DIV> <DIV style="border:1px solid black; box-sizing:border-box; display:flex; align-items:center; justify-content:center; scroll-snap-align:center; ">6</DIV> <DIV style="border:1px solid black; box-sizing:border-box; display:flex; align-items:center; justify-content:center; scroll-snap-align:center; ">7</DIV> <DIV style="border:1px solid black; box-sizing:border-box; display:flex; align-items:center; justify-content:center; scroll-snap-align:center; ">8</DIV> </DIV>
mandatory
この値が指定されているスクロール コンテナは、[スクロール操作が作動中でない間、および作動中のスクロールが終了したとき]は、妥当な留め位置が存在するならば、留められるものとする(留め位置が存在しなければ、留めも生じない)。
<DIV style="border:1px solid red; width:100px; height:100px; box-sizing:content-box; display:flex; overflow-x:scroll; scroll-snap-type:x mandatory; "> <DIV style="border:1px solid black; box-sizing:border-box; font-size:30px; flex:0 0 100px; width:100px; display:flex; align-items:center; justify-content:center; scroll-snap-align:start; ">1</DIV> <DIV style="border:1px solid black; box-sizing:border-box; font-size:30px; flex:0 0 100px; width:100px; display:flex; align-items:center; justify-content:center; scroll-snap-align:start; ">2</DIV> <DIV style="border:1px solid black; box-sizing:border-box; font-size:30px; flex:0 0 100px; width:100px; display:flex; align-items:center; justify-content:center; scroll-snap-align:start; ">3</DIV> <DIV style="border:1px solid black; box-sizing:border-box; font-size:30px; flex:0 0 100px; width:100px; display:flex; align-items:center; justify-content:center; scroll-snap-align:start; ">4</DIV> </DIV>
proximity
この値が指定されているスクロール コンテナに対しては、ユーザー エージェントは ― 所与のスクロール パラメーターに基づいて、自身の裁量で ― スクロールの終了時に留め位置に留めてよい。
<DIV style="border:1px solid red; width:100px; height:100px; box-sizing:content-box; display:flex; overflow-x:scroll; scroll-snap-type:x proximity; "> <DIV style="border:1px solid black; box-sizing:border-box; font-size:30px; flex:0 0 100px; width:100px; display:flex; align-items:center; justify-content:center; scroll-snap-align:start; ">1</DIV> <DIV style="border:1px solid black; box-sizing:border-box; font-size:30px; flex:0 0 100px; width:100px; display:flex; align-items:center; justify-content:center; scroll-snap-align:start; ">2</DIV> <DIV style="border:1px solid black; box-sizing:border-box; font-size:30px; flex:0 0 100px; width:100px; display:flex; align-items:center; justify-content:center; scroll-snap-align:start; ">3</DIV> <DIV style="border:1px solid black; box-sizing:border-box; font-size:30px; flex:0 0 100px; width:100px; display:flex; align-items:center; justify-content:center; scroll-snap-align:start; ">4</DIV> </DIV>
作者は、留め位置に mandatory を利用するときは、多様な[スクリーン サイズや、場合によっては内容サイズ]を考慮するべきである。留められている、かつスクロール域より大きい要素へのアクセスは、ユーザー エージェントにより取り扱われるが、特に、同じスクロール域内に 留め位置を供する内容、供さない内容が混在する場合、後者の内容は、スクリーンに比して長いときにアクセス不能になり得る。
所与のボックスのスクロール留めコンテナは、次で与えられる:
該当するものがない場合、ボックスにはスクロール留めコンテナはない。その場合、ボックスの留め位置は留めを誘発しないことになる。
¶省く
表示内容: |
表示内容: |