scroll-margin-right属性用于一次将所有滚动边距设置到元素的右侧。为scroll-margin-right指定的值确定应该本质上保留在快照端口之外的页面数量。
因此,scroll-margin-right值表示定义了滚动捕捉区域的起始点,该区域用于将该框捕捉到捕捉端口。
用法:
scroll-margin-right:length /* Or */ scroll-margin-right:Global_Value
属性值:该属性接受上面提到并在下面描述的two-properties:
- length:此属性引用以长度单位exp:px,em,vh等定义的值。
- Global_Values:此属性引用全局值,例如Inherit,Initial,unset等。
注意: scroll-margin-right不接受百分比值作为长度。
例:在此示例中,通过滚动到示例内容的“interfaces”中的两个之间的一个点,可以看到scroll-margin-right的效果。
<!DOCTYPE html>
<html>
<head>
<style>
img {
width:300px;
height:280px;
scroll-snap-align:none end;
}
.Gallery {
width:300px;
height:300px;
overflow-x:auto;
overflow-y:hidden;
white-space:nowrap;
scroll-snap-type:x mandatory;
}
</style>
</head>
<body>
<div class="photoGallery">
<img src=
"https://media.geeksforgeeks.org/wp-content/uploads/20200723131450/img6-300x82.png"
style="scroll-margin-right:50px;">
<img src=
"https://media.geeksforgeeks.org/wp-content/uploads/20200723131449/img5.jpeg"
style="scroll-margin-right:60px;">
<img src=
"https://media.geeksforgeeks.org/wp-content/uploads/20200723131452/img4-300x167.png"
style="scroll-margin-right:-50px;">
</div>
</body>
</html>
输出:
支持的浏览器:
- Chrome
- Firefox
- Opera
- Safari(部分支持)
- Edge
- Internet Explorer(不支持)
相关用法
- 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-right property。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。