Subscribed unsubscribe Subscribe Subscribe

HTML Element の幅と高さ、座標。

幅と高さ

Determining the dimensions of elements | MDN

補足

https://www.w3.org/TR/CSS22/box.html#box-dimensions f:id:ryotah:20170124143422p:plain

座標

補足

// https://github.com/oneuijs/You-Dont-Need-jQuery

function getOffset (el) {
  const box = el.getBoundingClientRect();
  
  return {
    top: box.top + window.pageYOffset - document.documentElement.clientTop,
    left: box.left + window.pageXOffset - document.documentElement.clientLeft
  };
}

参考