diff options
author | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:40:17 -0500 |
---|---|---|
committer | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:40:17 -0500 |
commit | 33058f2b292b3a581333bdfb21b8f671898c5060 (patch) | |
tree | 51c3e392513ec574331b2d3f85c394445ea803c6 /files/zh-cn/web/css/scroll-snap-points-y | |
parent | 8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff) | |
download | translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2 translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip |
initial commit
Diffstat (limited to 'files/zh-cn/web/css/scroll-snap-points-y')
-rw-r--r-- | files/zh-cn/web/css/scroll-snap-points-y/index.html | 141 |
1 files changed, 141 insertions, 0 deletions
diff --git a/files/zh-cn/web/css/scroll-snap-points-y/index.html b/files/zh-cn/web/css/scroll-snap-points-y/index.html new file mode 100644 index 0000000000..5e2aa4f4de --- /dev/null +++ b/files/zh-cn/web/css/scroll-snap-points-y/index.html @@ -0,0 +1,141 @@ +--- +title: scroll-snap-points-y +slug: Web/CSS/scroll-snap-points-y +tags: + - CSS + - css snap +translation_of: Web/CSS/scroll-snap-points-y +--- +<div>{{CSSRef}}{{SeeCompatTable}}{{deprecated_header}}</div> + +<h2 id="摘要">摘要</h2> + +<p><strong><code>scroll-snap-points-y</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-y: none; + +/* 重复的snap点 */ +scroll-snap-points-y: repeat(400px); + +/* 全局值 */ +scroll-snap-points-y: inherit; +scroll-snap-points-y: initial; +scroll-snap-points-y: unset; +</pre> + +<h3 id="Values">Values</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> + +<pre class="syntaxbox">{{csssyntax}}</pre> + +<h2 id="示例">示例</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 { + 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; +}</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>{{CompatNo}}</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> |