Development/Javascript
[Javascript] getBoundingClientRect()
레오나르도 다빈츠
2021. 12. 27. 10:36
◽ getBoundingClientRect()
이 method가 return하는 width, height 속성값은 padding과 border-width를 포함한 것이다.
즉, 엘리먼트 자체의 width + padding + border-width를 다 더한값이다.
◽ getBoundingClientRect()의 속성
- x: x 좌표 값
- y: y 좌표 값
- width
- height
- top
- right
- bottom
- left
// 이렇게 사용할 수 있다.
getBoundingClientRect().top
출처 및 참조
https://developer.mozilla.org/ko/docs/Web/API/Element/getBoundingClientRect