CSS参考手册
杂项 | Miscellaneous
scroll-snap-points-x
scroll-snap-points-x
弃用
该功能已从Web标准中删除。尽管一些浏览器可能仍然支持它,但它正在被丢弃。避免使用它并尽可能更新现有的代码; 请参阅本页面底部的兼容性表格来指导您的决定。请注意,此功能可能随时停止工作。
scroll-snap-points-x
CSS属性定义的捕捉点它们被施加到滚动容器的内容物中的水平位置。
/* Keyword value */
scroll-snap-points-x: none;
/* Repeating snap points */
scroll-snap-points-x: repeat(400px);
/* Global values */
scroll-snap-points-x: inherit;
scroll-snap-points-x: initial;
scroll-snap-points-x: 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>)
定义从容器的相关起始边缘开始定义捕捉点的间隔。只允许积极的长度。百分比是指容器的宽度。
形式语法
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 {
width: 200px;
overflow: auto;
white-space: nowrap;
scroll-snap-points-x: repeat(100%);
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 |
杂项 | Miscellaneous相关
层叠样式表( Cascading Style Sheets )是一种用来表现 HTML 或 XML 等文件样式的计算机语言。CSS 不仅可以静态地修饰网页,还可以配合各种脚本语言动态地对网页各元素进行格式化。