首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

scroll-snap-points-y

scroll-snap-points-y

弃用

该功能已从Web标准中删除。尽管一些浏览器可能仍然支持它,但它正在被丢弃。避免使用它并尽可能更新现有的代码; 请参阅本页面底部的兼容性表格来指导您的决定。请注意,此功能可能随时停止工作。

scroll-snap-points-y CSS属性定义的捕捉点它们被施加到滚动容器的内容物内的垂直位置。

代码语言:javascript
复制
/* 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滚动容器不定义任何捕捉点。滚动容器内的元素仍可以代表滚动容器定义捕捉点。

repeat(<length-percentage>)定义从容器的相关起始边缘开始定义捕捉点的间隔。只允许积极的长度。百分比是指容器的宽度。

形式语法

代码语言:javascript
复制
none | repeat( <length-percentage> )where 
<length-percentage> = <length> | <percentage>

例子

HTML内容

代码语言:javascript
复制
<div id="container">
? <div>1</div>
? <div>2</div>
? <div>3</div>
</div>

CSS内容

代码语言:javascript
复制
#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

扫码关注腾讯云开发者

领取腾讯云代金券

http://www.vxiaotou.com