scroll-margin-block-end 屬性用於一次將所有滾動邊距設置為滾動元素的結束側。此屬性定義塊尺寸末尾的滾動捕捉區域的邊距,用於將此框捕捉到捕捉端口。
用法:
scroll-margin-block-end:length /* Or */ scroll-margin-block-end:Global_Values
屬性值:此屬性接受上麵提到和下麵描述的兩個屬性:
- length:這個屬性是指用長度單位定義的值,如 em、px、rem、vh 等。
- Global_Values:此屬性引用全局值,例如Inherit,Initial,unset等。
注意: scroll-margin-block-端不接受百分比值作為長度。
例:在此示例中,您可以通過滾動到示例內容的兩個 “interfaces” 之間的中間點來查看 scroll-margin-block-end 的效果。
HTML
<!DOCTYPE html>
<html>
<head>
<style>
.interfaces {
width:278px;
height:296px;
scroll-snap-align:end none;
display:flex;
align-items:center;
justify-content:center;
font-size:60px;
color:white;
}
.doc {
width:300px;
height:300px;
overflow-x:hidden;
overflow-y:auto;
white-space:nowrap;
scroll-snap-type:y mandatory;
}
</style>
</head>
<body>
<div class="doc">
<div class="interfaces" style=
"background-color:rgb(178, 248, 16);
scroll-margin-block-end:90px;">
Geek 1
</div>
<div class="interfaces" style=
"color:black;
scroll-margin-block-end:90px;">
Geek 2
</div>
<div class="interfaces" style=
"background-color:green;
scroll-margin-block-end:90px;">
Geek 3
</div>
<div class="interfaces" style=
"color:green;
scroll-margin-block-end:90px;">
Geek 4
</div>
<div class="interfaces" style=
"background-color:rgb(34, 177, 34);
scroll-margin-block-end:90px;">
Geek 5
</div>
<div class="interfaces" style=
"background-color:rgb(108, 216, 162);
scroll-margin-block-end:90px;">
Geek 6
</div>
</div>
</body>
</html>
輸出:此示例顯示滾動時 90 像素的對齊區域。
支持的瀏覽器:
- Chrome
- Opera
- Edge
- Firefox
相關用法
- CSS transition-property用法及代碼示例
- CSS table-layout用法及代碼示例
- CSS text-align用法及代碼示例
- CSS border-top-width用法及代碼示例
- CSS isolation屬性用法及代碼示例
- CSS border-inline-start-style屬性用法及代碼示例
- CSS column-rule-width用法及代碼示例
- CSS word-spacing用法及代碼示例
- CSS animation-delay用法及代碼示例
- CSS margin-top用法及代碼示例
- CSS grid屬性用法及代碼示例
- CSS font-size-adjust用法及代碼示例
- CSS visibility屬性用法及代碼示例
- CSS Display屬性用法及代碼示例
- CSS grid-template-columns用法及代碼示例
- CSS height屬性用法及代碼示例
- CSS transform-origin用法及代碼示例
- CSS animation-name用法及代碼示例
- CSS flex-wrap用法及代碼示例
注:本文由純淨天空篩選整理自thacker_shahid大神的英文原創作品 CSS scroll-margin-block-end property。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。