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/api/element/scrollby | |
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/api/element/scrollby')
-rw-r--r-- | files/zh-cn/web/api/element/scrollby/index.html | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/files/zh-cn/web/api/element/scrollby/index.html b/files/zh-cn/web/api/element/scrollby/index.html new file mode 100644 index 0000000000..1bad7f7a56 --- /dev/null +++ b/files/zh-cn/web/api/element/scrollby/index.html @@ -0,0 +1,72 @@ +--- +title: Element.scrollBy() +slug: Web/API/Element/scrollBy +tags: + - API + - Element + - Method + - Reference + - scrollBy +translation_of: Web/API/Element/scrollBy +--- +<div>{{ APIRef() }}</div> + +<p> <strong><code>scrollBy()</code></strong> 方法是使得元素滚动一段特定距离的 {{domxref("Element")}} 接口。</p> + +<h2 id="Syntax">Syntax</h2> + +<pre class="syntaxbox">element.scrollBy(<em>x-coord</em>, <em>y-coord</em>); +element.scrollBy(options) +</pre> + +<h3 id="Parameters">Parameters</h3> + +<ul> + <li><code>x-coord</code> 是元素要在横轴上滚动的距离。</li> + <li><code>y-coord</code> 是元素要在纵轴上滚动的距离。</li> +</ul> + +<p>- or -</p> + +<ul> + <li><code>options</code> 是一个 {{domxref("ScrollToOptions")}} 字典。</li> +</ul> + +<h2 id="例子">例子</h2> + +<pre class="brush: js">// 让元素滚动 +element.scrollBy(300, 300); +</pre> + +<p>使用 <code>options</code>:</p> + +<pre class="brush: js">element.scrollBy({ + top: 100, + left: 100, + behavior: 'smooth' +});</pre> + +<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('CSSOM View', '#dom-element-scrollby-options-options', 'element.scrollBy()') }}</td> + <td>{{ Spec2('CSSOM View') }}</td> + <td>Initial definition.</td> + </tr> + </tbody> +</table> + +<h2 id="浏览器兼容性"> 浏览器兼容性</h2> + + + +<p>{{Compat("api.Element.scrollBy")}}</p> |