CSS

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 valuenone
应用对象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

浏览器兼容性

FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari (WebKit)
Basic supportNo support39.0 (39.0)No supportNo support9-webkit

FeatureAndroidFirefox Mobile (Gecko)Firefox OSIE PhoneOpera MobileSafari Mobile
Basic supportNo support39.0 (39.0)139.0 (39.0)No supportNo support9-webkit