LoginSignup
44
43

More than 5 years have passed since last update.

elementとwindowサイズの取得

Last updated at Posted at 2014-07-12

サイズの取得

window_size.png{: style=”width: 200px; vertical-align:middle;”}

offsetTop:要素が始まる場所と上の要素の位置

offsetHeight:指定した要素の高さ

document.body.scrollTop:windowのtopから、要素のtopまでの位置

window.innerHeight:ウィンドウの高さ

getBoundingClientRect

getBoundingClientRect.png

getBoundingClientRect(This is an experimental technology)

example
$('div')[1].getBoundingClientRect()
ClientRect {height: 1338, width: 320, left: 0, bottom: 1241, right: 320}
bottom: 1241
height: 1338
left: 0
right: 320
top: -97
width: 320
44
43
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
44
43