scroll-margin-bottom属性用于将所有滚动边距一次性设置到元素的底部。为scroll-margin-bottom指定的值确定应该主要显示在支持范围之外的页面的多少。
因此,scroll-margin-bottom值代表定义了滚动捕捉区域的起始位置,该区域用于将该框捕捉到捕捉端口。
用法:
scroll-margin-bottom:length /* Or */ scroll-margin-bottom:Global_Values
属性值:该属性接受上面提到并在下面描述的two-properties:
- length:此属性引用以长度单位定义的值:px,rem,em,vh等。
- Global_Values:此属性引用全局值,例如初始,继承,未设置等。
注意:scroll-margin-bottom不接受百分比值作为长度。
例:在此示例中,通过滚动到示例内容的“interfaces”中的两个之间的一个点,可以看到scroll-margin-bottom的效果。
HTML
<!DOCTYPE html>
<html>
<head>
<style>
.scroller {
width:300px;
height:300px;
overflow-x:hidden;
overflow-y:auto;
scroll-snap-type:y mandatory;
}
.scroller > div {
width:300px;
height:300px;
font-size:50px;
color:white;
display:flex;
align-items:center;
justify-content:center;
scroll-snap-align:end none;
}
.scroller div:nth-child(odd){
background-color:green;
scroll-margin-bottom:1rem;
}
.scroller div:nth-child(even){
background-color:rgb(160, 231, 45);
scroll-margin-bottom:3rem;
}
</style>
</head>
<body>
<div class="scroller">
<div>Geeks</div>
<div>for</div>
<div>Geeks</div>
<div>for</div>
<div>Geeks</div>
</div>
</body>
</html>
输出:
支持的浏览器:
- Chrome
- Firefox
- Edge
- Opera
- Safari(partially supported)
相关用法
- 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 grid-template-columns用法及代码示例
- CSS height属性用法及代码示例
- CSS transform-origin用法及代码示例
- CSS animation-name用法及代码示例
- CSS flex-wrap用法及代码示例
- CSS align-content用法及代码示例
- CSS page-break-before属性用法及代码示例
- CSS empty-cells用法及代码示例
注:本文由纯净天空筛选整理自thacker_shahid大神的英文原创作品 CSS scroll-margin-bottom Property。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。