요소 사이즈와 스크롤

<div id="example">
  ...텍스트...
</div>
<style>
  #example {
    width: 300px;
    height: 200px;
    border: 25px solid #E8C48F;
    padding: 20px;
    overflow: auto;
  }
</style>

image.png

기하 프로퍼티

image.png

offsetParent와 offsetLeft, offsetTop

offsetLeft, offsetTop 프로퍼티는 offsetParent를 기준으로 각각 요소가 오른쪽으로, 아래쪽으로 얼마나 떨어져 있는지를 나타낸다.

아래의 경우엔 offsetParent가 null이 될 수 있다.

  1. 화면에 보이지 않는 요소(CSS display 프로퍼티가 none이거나 문서 내에 있지 않은 요소)
  2. <body>와 <html>
  3. position 프로퍼티가 fixed인 요소