scroll-snap-points-y
弃用
该功能已从Web标准中删除。尽管一些浏览器可能仍然支持它,但它正在被丢弃。避免使用它并尽可能更新现有的代码; 请参阅本页面底部的兼容性表格来指导您的决定。请注意,此功能可能随时停止工作。
scroll-snap-points-y
CSS属性定义的捕捉点它们被施加到滚动容器的内容物内的垂直位置。
/* Keyword value */
scroll-snap-points-y: none;
/* Repeated snap points */
scroll-snap-points-y: repeat(400px
/* Global values */
scroll-snap-points-y: inherit;
scroll-snap-points-y: initial;
scroll-snap-points-y: unset;
Initial value | none |
---|---|
应用对象 | scroll containers |
是否可继承 | no |
百分比值 | relative to same axis of the padding-box of the scroll container |
媒体 | interactive |
计算值 | as specified, but with relative lengths converted into absolute lengths |
动画类型 | discrete |
规范顺序 | the unique non-ambiguous order defined by the formal grammar |
语法
值
none
滚动容器不定义任何捕捉点。滚动容器内的元素仍可以代表滚动容器定义捕捉点。
形式语法
none | repeat( <length-percentage> )where
<length-percentage> = <length> | <percentage>
例子
HTML内容
<div id="container">
<div>1</div>
<div>2</div>
<div>3</div>
</div>
CSS内容
#container {
height: 200px;
width: 220px;
overflow-x: hidden;
overflow-y: auto;
scroll-snap-points-y: repeat(200px
scroll-snap-type: mandatory;
font-size: 0;
}
#container > div {
width: 200px;
height: 200px;
display: inline-block;
line-height: 200px;
text-align: center;
font-size: 100px;
}
#container > div:nth-child(even) {
background-color: #87EA87;
}
#container > div:nth-child(odd) {
background-color: #87CCEA;
}
规范
这个属性曾经在CSS Scroll Snap Points Module早期版本中定义过,但后来从规范中删除了,以支持基于元素的snapping。
浏览器兼容性
Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari (WebKit) |
---|---|---|---|---|---|
Basic support | No support | 39.0 (39.0) | No support | No support | 9-webkit |
Feature | Android | Firefox Mobile (Gecko) | Firefox OS | IE Phone | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|---|
Basic support | No support | 39.0 (39.0)1 | 39.0 (39.0) | No support | No support | 9-webkit |