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/ja/web/api/element/scrolltop/index.html | 94 +++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 files/ja/web/api/element/scrolltop/index.html (limited to 'files/ja/web/api/element/scrolltop') diff --git a/files/ja/web/api/element/scrolltop/index.html b/files/ja/web/api/element/scrolltop/index.html new file mode 100644 index 0000000000..12fa3678bf --- /dev/null +++ b/files/ja/web/api/element/scrolltop/index.html @@ -0,0 +1,94 @@ +--- +title: Element.scrollTop +slug: Web/API/Element/scrollTop +tags: + - API + - CSSOM View + - NeedsArtUpdate + - NeedsMarkupWork + - Property + - Reference + - プロパティ +translation_of: Web/API/Element/scrollTop +--- +
{{APIRef("DOM")}}
+ +

Element.scrollTop プロパティは、要素の内容が垂直にスクロールするピクセル数を取得または設定します。

+ +

要素の scrollTop の値は、要素の上から最も上の表示されているコンテンツまでの距離を測ったものです。要素の内容が垂直スクロールバーを生成しなかった場合は、 scrollTop の値は 0 になります。

+ +

scrollTop がルート要素 (<html> 要素) に対して使用されると、ウィンドウの scrollY が返されます。 これは scrollTop の特例です

+ +
+

画面の拡大縮小を使用するシステムでは、 scrollTop が小数になることがあります。

+
+ +

構文

+ +
// スクロールしたピクセル数を取得
+var intElemScrollTop = someElement.scrollTop;
+
+ +

このコードを実行した後、 intElemScrollTop はこの要素 ({{domxref("Element")}}) が上方向にスクロールしたピクセル数に対応した整数になります。

+ +
// スクロールするピクセル数を設定
+element.scrollTop = intValue;
+
+ +

scrollTop は任意の整数値で設定することができます。しかし、

+ + + +

+ +
+
+

padding-top

+If you can see this, scrollTop = 0 + +

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.

+If you can see this, scrollTop is > 0 + +

Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

+If you can see this, scrollTop is maxed-out + +

padding-bottom

+
+Left Top Right Bottom margin-top margin-bottom border-top border-bottom
+ +

仕様書

+ + + + + + + + + + + + + + + + +
仕様書状態備考
{{SpecName('CSSOM View', '#dom-element-scrolltop', 'scrollTop')}}{{Spec2("CSSOM View")}}
+ +

ブラウザーの互換性

+ + + +

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

+ +

関連情報

+ + -- cgit v1.2.3-54-g00ecf