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-destination | |
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-destination')
-rw-r--r-- | files/zh-cn/web/css/scroll-snap-destination/index.html | 192 |
1 files changed, 192 insertions, 0 deletions
diff --git a/files/zh-cn/web/css/scroll-snap-destination/index.html b/files/zh-cn/web/css/scroll-snap-destination/index.html new file mode 100644 index 0000000000..8e33857321 --- /dev/null +++ b/files/zh-cn/web/css/scroll-snap-destination/index.html @@ -0,0 +1,192 @@ +--- +title: scroll-snap-destination +slug: Web/CSS/scroll-snap-destination +translation_of: Web/CSS/scroll-snap-destination +--- +<div>{{CSSRef}}{{SeeCompatTable}}</div> + +<h2 id="摘要">摘要</h2> + +<p><strong><code>scroll-snap-destination</code></strong> <a href="/en-US/docs/Web/CSS">CSS</a>属性定义滚动容器的可视化{{Glossary("viewport")}} 中元素snap点的x和y坐标位置。</p> + +<p>{{cssinfo}}</p> + +<h2 id="语法">语法</h2> + +<pre class="brush: css">/* <位置>值 */ +scroll-snap-destination: 400px 600px; + +/* 全局值 */ +scroll-snap-destination: inherit; +scroll-snap-destination: initial; +scroll-snap-destination: unset; +</pre> + +<h3 id="取值">取值</h3> + +<dl> + <dt><code><position></code></dt> + <dd>定义从滚动容器的可视视图边缘开始偏移的snap坐标。第一个值给定了snap坐标的x坐标,第二个值为它的y坐标。</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> + <p>At coordinate (0, 0)</p> + <div class="scrollContainer destination0"> + <div>1</div> + <div>2</div> + <div>3</div> + </div> + </div> + + <div> + <p>At coordinate (25, 0)</p> + <div class="scrollContainer destination25"> + <div>1</div> + <div>2</div> + <div>3</div> + </div> + </div> + + <div> + <p>At coordinate (50, 0)</p> + <div class="scrollContainer destination50"> + <div>1</div> + <div>2</div> + <div>3</div> + </div> + </div> +</div> +</pre> + +<h3 id="CSS内容">CSS内容</h3> + +<pre class="brush: css">#container { + display: flex; +} + +#container > div:nth-child(-n+2) { + margin-right: 20px; +} + +.scrollContainer { + width: 100px; + overflow: auto; + white-space: nowrap; + scroll-snap-points-x: repeat(100%); + scroll-snap-type: mandatory; + scroll-snap-destination: 20px 0; + font-size: 0; +} + +.destination0 { + scroll-snap-destination: 0 0; +} + +.destination25 { + scroll-snap-destination: 25px 0; +} + +.destination50 { + scroll-snap-destination: 50px 0; +} + +.scrollContainer > div { + width: 100px; + height: 100px; + display: inline-block; + line-height: 100px; + text-align: center; + font-size: 50px; +} + +.scrollContainer > div:nth-child(even) { + background-color: #87EA87; +} + +.scrollContainer > div:nth-child(odd) { + background-color: #87CCEA; +}</pre> + +<p>{{EmbedLiveSample("Example", "100%", "170")}}</p> + +<h2 id="规范">规范</h2> + +<table class="standard-table"> + <thead> + <tr> + <th scope="col">规范名称</th> + <th scope="col">状态</th> + <th scope="col">评论</th> + </tr> + </thead> + <tbody> + <tr> + <td>{{SpecName("CSS Scroll Snap Points", "#propdef-scroll-snap-destination", "scroll-snap-destination")}}</td> + <td>{{Spec2("CSS Scroll Snap Points")}}</td> + <td>Initial definition</td> + </tr> + </tbody> +</table> + +<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>{{CompatNo}}</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>{{CompatNo}}</td> + </tr> + </tbody> +</table> +</div> + +<p>[1] 在Firefox移动版上,从内核Gecko 39开始可用,但是低于 <code>layout.css.vertical-text.enabled</code>优先级,默认不可用。</p> |