문서의 기하학적 특성
요소들의 크기와 위치 학습
getBoundingClientRect
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title></title>
<style>
.box {
width: 300px;
height: 300px;
padding: 20px;
margin: 20px;
border: 50px solid blue;
}
</style>
</head>
<body>
<div class="box">Coding</div>
<script>
console.log(document.querySelector('.box').getBoundingClientRect());
</script>
</body>Last updated