From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- files/zh-cn/web/api/element/scrollby/index.html | 72 +++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 files/zh-cn/web/api/element/scrollby/index.html (limited to 'files/zh-cn/web/api/element/scrollby') 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 +--- +
{{ APIRef() }}
+ +

 scrollBy() 方法是使得元素滚动一段特定距离的 {{domxref("Element")}} 接口。

+ +

Syntax

+ +
element.scrollBy(x-coord, y-coord);
+element.scrollBy(options)
+
+ +

Parameters

+ + + +

- or -

+ + + +

例子

+ +
// 让元素滚动
+element.scrollBy(300, 300);
+
+ +

使用 options:

+ +
element.scrollBy({
+  top: 100,
+  left: 100,
+  behavior: 'smooth'
+});
+ +

规范

+ + + + + + + + + + + + + + + + +
规范状态注释
{{ SpecName('CSSOM View', '#dom-element-scrollby-options-options', 'element.scrollBy()') }}{{ Spec2('CSSOM View') }}Initial definition.
+ +

 浏览器兼容性

+ + + +

{{Compat("api.Element.scrollBy")}}

-- cgit v1.2.3-54-g00ecf