aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/api/window/scrollto
diff options
context:
space:
mode:
authorPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
committerPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
commit33058f2b292b3a581333bdfb21b8f671898c5060 (patch)
tree51c3e392513ec574331b2d3f85c394445ea803c6 /files/zh-cn/web/api/window/scrollto
parent8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff)
downloadtranslated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip
initial commit
Diffstat (limited to 'files/zh-cn/web/api/window/scrollto')
-rw-r--r--files/zh-cn/web/api/window/scrollto/index.html58
1 files changed, 58 insertions, 0 deletions
diff --git a/files/zh-cn/web/api/window/scrollto/index.html b/files/zh-cn/web/api/window/scrollto/index.html
new file mode 100644
index 0000000000..715e3f0190
--- /dev/null
+++ b/files/zh-cn/web/api/window/scrollto/index.html
@@ -0,0 +1,58 @@
+---
+title: Window.scrollTo()
+slug: Web/API/Window/scrollTo
+translation_of: Web/API/Window/scrollTo
+---
+<div>{{ APIRef }}</div>
+
+<h2 id="Summary" name="Summary">摘要</h2>
+
+<p>滚动到文档中的某个坐标。</p>
+
+<h2 id="Syntax" name="Syntax">语法</h2>
+
+<pre><code>window.scrollTo(x<em>-coord</em>,<em>y-coord</em> )</code>
+
+<code>window.scrollTo(options)</code></pre>
+
+<h3 id="Parameters" name="Parameters">参数</h3>
+
+<ul>
+ <li><code>x-coord</code> 是文档中的横轴坐标。</li>
+ <li><code>y-coord</code> 是文档中的纵轴坐标。</li>
+ <li><code>options</code> 是一个包含三个属性的对象:</li>
+</ul>
+
+<ol>
+ <li><code><em>top</em></code> 等同于  <code><em>y-coord</em></code></li>
+ <li><font face="consolas, Liberation Mono, courier, monospace"><span style="background-color: rgba(220, 220, 220, 0.5);">left</span></font> 等同于  <code>x<em>-coord</em></code></li>
+ <li><code><em>behavior</em></code><em>  类型String,表示滚动行为,支持参数 smooth(平滑滚动),instant(瞬间滚动),默认值auto,实测效果等同于instant</em></li>
+</ol>
+
+<dl>
+</dl>
+
+<h2 id="Example" name="Example">例子</h2>
+
+<pre>window.scrollTo( 0, 1000 );
+
+<code>// 设置滚动行为改为平滑的滚动
+window.scrollTo({
+  top: 1000,
+  behavior: "smooth"
+});</code>
+</pre>
+
+<h2 id="Notes" name="Notes">注意</h2>
+
+<p>该函数实际上和 <a href="/en-US/docs/DOM/Window.scroll">window.scroll</a>是一样的。 相对滚动可以参考 <a href="/en-US/docs/DOM/Window.scrollBy">window.scrollBy</a>,<a href="/en-US/docs/DOM/Window.scrollByLines">window.scrollByLines</a>,和 <a href="/en-US/docs/DOM/Window.scrollByPages">window.scrollByPages</a>。</p>
+
+<h2 id="Specification" name="Specification">规范</h2>
+
+<p>{{dom0}}</p>
+
+<h2 id="浏览器兼容性">浏览器兼容性</h2>
+
+<div class="hidden">兼容性表格由结构化的数据自动生成. 如果你想功能数据, 请点击进入 <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> 给我们提交 pull request.</div>
+
+<p>{{Compat("api.Window.scrollTo")}}</p>