aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/css/scroll-snap-points-x/index.html
diff options
context:
space:
mode:
Diffstat (limited to 'files/zh-cn/web/css/scroll-snap-points-x/index.html')
-rw-r--r--files/zh-cn/web/css/scroll-snap-points-x/index.html140
1 files changed, 140 insertions, 0 deletions
diff --git a/files/zh-cn/web/css/scroll-snap-points-x/index.html b/files/zh-cn/web/css/scroll-snap-points-x/index.html
new file mode 100644
index 0000000000..29ed5bd8b8
--- /dev/null
+++ b/files/zh-cn/web/css/scroll-snap-points-x/index.html
@@ -0,0 +1,140 @@
+---
+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(&lt;长度&gt;)</code></dt>
+ <dd>定义snap点的一个间隔,从容器相关的边缘开始。仅允许正数长度。</dd>
+</dl>
+
+<h3 id="正式语法">正式语法</h3>
+
+<pre class="syntaxbox">{{csssyntax}}</pre>
+
+<h2 id="Example" name="Example">示例</h2>
+
+<h3 id="HTML内容">HTML内容</h3>
+
+<pre class="brush: html">&lt;div id="container"&gt;
+  &lt;div&gt;1&lt;/div&gt;
+  &lt;div&gt;2&lt;/div&gt;
+  &lt;div&gt;3&lt;/div&gt;
+&lt;/div&gt;</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 &gt; div {
+ width: 200px;
+ height: 200px;
+ display: inline-block;
+ line-height: 200px;
+ text-align: center;
+ font-size: 100px;
+}
+
+#container &gt; div:nth-child(even) {
+ background-color: #87ea87;
+}
+
+#container &gt; 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>
+
+<p>{{CompatibilityTable}}</p>
+
+<div id="compat-desktop">
+<table class="compat-table">
+ <tbody>
+ <tr>
+ <th>特性</th>
+ <th>Chrome</th>
+ <th>Firefox (Gecko)</th>
+ <th>Internet Explorer</th>
+ <th>Opera</th>
+ <th>Safari (WebKit)</th>
+ </tr>
+ <tr>
+ <td>支持度</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatGeckoDesktop("39.0")}}</td>
+ <td>{{CompatNo}}</td>
+ <td>{{CompatNo}}</td>
+ <td>9{{property_prefix("-webkit")}}</td>
+ </tr>
+ </tbody>
+</table>
+</div>
+
+<div id="compat-mobile">
+<table class="compat-table">
+ <tbody>
+ <tr>
+ <th>特性</th>
+ <th>Android</th>
+ <th>Firefox Mobile (Gecko)</th>
+ <th>Firefox OS</th>
+ <th>IE Phone</th>
+ <th>Opera Mobile</th>
+ <th>Safari Mobile</th>
+ </tr>
+ <tr>
+ <td>支持度</td>
+ <td>{{CompatNo}}</td>
+ <td>{{CompatGeckoMobile("39.0")}}<sup>[1]</sup></td>
+ <td>{{CompatGeckoMobile("39.0")}}</td>
+ <td>{{CompatNo}}</td>
+ <td>{{CompatNo}}</td>
+ <td>9{{property_prefix("-webkit")}}</td>
+ </tr>
+ </tbody>
+</table>
+</div>
+
+<p>[1] 在Firefox移动版上,从内核Gecko 39开始可用,但是低于 <code>layout.css.vertical-text.enabled</code>优先级,默认不可用。</p>