scroll-margin-right
scroll-margin-right 屬性定義了滾動捕捉區域的右外邊距,用於將此框捕捉到捕捉埠。滾動捕捉區域是透過獲取變換後的邊框、找到其矩形邊界框(在滾動容器的座標空間中軸對齊),然後新增指定的偏移量來確定的。
試一試
scroll-margin-right: 0;
scroll-margin-right: 20px;
scroll-margin-right: 2em;
<section class="default-example" id="default-example">
<div class="scroller">
<div>1</div>
<div id="example-element">2</div>
<div>3</div>
</div>
<div class="info">Scroll »</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: white;
font-size: 30px;
display: flex;
align-items: center;
justify-content: center;
scroll-snap-align: end;
}
.scroller > div:nth-child(even) {
background-color: white;
color: rebeccapurple;
}
語法
css
/* <length> values */
scroll-margin-right: 10px;
scroll-margin-right: 1em;
/* Global values */
scroll-margin-right: inherit;
scroll-margin-right: initial;
scroll-margin-right: revert;
scroll-margin-right: revert-layer;
scroll-margin-right: unset;
值
<length>-
從滾動容器右邊緣向外的偏移量。
正式定義
正式語法
scroll-margin-right =
<length>
規範
| 規範 |
|---|
| CSS 滾動捕捉模組級別 1 # margin-longhands-physical |
瀏覽器相容性
載入中…