scroll-margin-bottom
scroll-margin-bottom 屬性定義了滾動捕捉區域的下邊距,該區域用於將此框捕捉到捕捉視口。滾動捕捉區域的確定方式是:首先獲取變換後的邊框,找到其矩形邊界框(在滾動容器的座標空間中與軸對齊),然後新增指定的外部偏移。
試一試
scroll-margin-bottom: 0;
scroll-margin-bottom: 20px;
scroll-margin-bottom: 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 .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: 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-bottom: 10px;
scroll-margin-bottom: 1em;
/* Global values */
scroll-margin-bottom: inherit;
scroll-margin-bottom: initial;
scroll-margin-bottom: revert;
scroll-margin-bottom: revert-layer;
scroll-margin-bottom: unset;
值
<length>-
從滾動容器下邊緣向外偏移。
正式定義
正式語法
scroll-margin-bottom =
<length>
規範
| 規範 |
|---|
| CSS 滾動捕捉模組級別 1 # margin-longhands-physical |
瀏覽器相容性
載入中…