blob: 878e03b57f26050aed9e5f63645191e6cc075d29 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
---
title: scroll-snap-points-x
slug: Web/CSS/scroll-snap-points-x
tags:
- CSS
- css snap
translation_of: Web/CSS/scroll-snap-points-x
---
<div>{{CSSRef}}{{SeeCompatTable}}{{deprecated_header}}</div>
<h2 id="摘要">摘要</h2>
<p><strong><code>scroll-snap-points-x</code></strong> <a href="/en-US/docs/Web/CSS">CSS</a>属性定义滚动容器中内容的snap点的水平位置。</p>
<p>{{cssinfo}}</p>
<h2 id="语法">语法</h2>
<pre class="brush: css">/* 关键值 */
scroll-snap-points-x: none;
/* 重复的snap点 */
scroll-snap-points-x: repeat(400px);
/* 全局值 */
scroll-snap-points-x: inherit;
scroll-snap-points-x: initial;
scroll-snap-points-x: unset;
</pre>
<h3 id="取值">取值</h3>
<dl>
<dt><code>none</code></dt>
<dd>滚动容器没有定义任何snap点。Elements within the scroll container may still define snap points of behalf of the scroll container.(i don't understand this statement)</dd>
<dt><code>repeat(<长度>)</code></dt>
<dd>定义snap点的一个间隔,从容器相关的边缘开始。仅允许正数长度。</dd>
</dl>
<h3 id="正式语法">正式语法</h3>
{{csssyntax}}
<h2 id="Example" name="Example">示例</h2>
<h3 id="HTML内容">HTML内容</h3>
<pre class="brush: html"><div id="container">
<div>1</div>
<div>2</div>
<div>3</div>
</div></pre>
<h3 id="CSS内容">CSS内容</h3>
<pre class="brush: 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;
}</pre>
<p>{{EmbedLiveSample("Example", 220, 220)}}</p>
<h2 id="规范">规范</h2>
<p>此属性曾定义在<a href="http://www.w3.org/TR/2015/WD-css-snappoints-1-20150326/#scroll-snap-points">early draft of CSS Scroll Snap Points Module</a>中,但是后来在<a href="https://lists.w3.org/Archives/Public/www-style/2015Nov/0266.html">in favor of element-based snapping</a>规范中被<a href="https://github.com/w3c/csswg-drafts/commit/922af86be789222b8490c92038d1a5142e1c1198">移除</a>。</p>
<h2 id="浏览器兼容性">浏览器兼容性</h2>
{{Compat("css.properties.scroll-snap-points-x")}}
|