弃用
This feature is no longer recommended. Though some browsers might still support it, it may have already been removed from the relevant web standards, may be in the process of being dropped, or may only be kept for compatibility purposes. Avoid using it, and update existing code if possible; see the
兼容性表格
at the bottom of this page to guide your decision. Be aware that this feature may cease to work at any time.
scroll-snap-type-x
CSS
property defines how strictly snap points are enforced on the horizontal axis of the scroll container in case there is one.
Specifying any precise animations or physics used to enforce those snap points is not covered by this property but instead left up to the user agent.
/* Keyword values */ scroll-snap-type-x: none; scroll-snap-type-x: mandatory; scroll-snap-type-x: proximity; /* Global values */ scroll-snap-type-x: inherit; scroll-snap-type-x: initial; scroll-snap-type-x: unset;
none
mandatory
The visual viewport of this scroll container will rest on a snap point if it isn't currently scrolled horizontally. That means it snaps on that point when the scroll action finished, if possible. If content is added, moved, deleted or resized the scroll offset will be adjusted to maintain the resting on that snap point.
proximity
The visual viewport of this scroll container may come to rest on a snap point if it isn't currently scrolled horizontally considering the user agent's scroll parameters. If content is added, moved, deleted or resized the scroll offset may be adjusted to maintain the resting on that snap point.
| 初始值 |
none
|
|---|---|
| 适用于 | scroll containers |
| 继承 | no |
| 计算值 | 如指定 |
| 动画类型 | discrete |
none | mandatory | proximity
Not part of any standard.
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
更新 GitHub 上的兼容性数据| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
scroll-snap-type-x
弃用
非标
|
Chrome 不支持 No | Edge 不支持 No | Firefox 不支持 39 — 68 | IE 不支持 No | Opera 不支持 No | Safari 完整支持 9 | WebView Android 不支持 No | Chrome Android 不支持 No | Firefox Android 不支持 39 — 68 | Opera Android 不支持 No | Safari iOS 完整支持 9 | Samsung Internet Android 不支持 No |
完整支持
不支持
非标。预期跨浏览器支持较差。
弃用。不要用于新网站。
scroll-margin
scroll-margin-block
scroll-margin-block-end
scroll-margin-block-start
scroll-margin-bottom
scroll-margin-inline
scroll-margin-inline-end
scroll-margin-inline-start
scroll-margin-left
scroll-margin-right
scroll-margin-top
scroll-padding
scroll-padding-block
scroll-padding-block-end
scroll-padding-block-start
scroll-padding-bottom
scroll-padding-inline
scroll-padding-inline-end
scroll-padding-inline-start
scroll-padding-left
scroll-padding-right
scroll-padding-top
scroll-snap-align
scroll-snap-coordinate
scroll-snap-destination
scroll-snap-points-x
scroll-snap-points-y
scroll-snap-stop
scroll-snap-type
scroll-snap-type-x
scroll-snap-type-y