• 회원가입
  • 로그인
  • 구글아이디로 로그인

[DOM_Element] JS - offsetHeight 속성 - 가시높이 (= 요소실제높이 = 요소높이 height+ + padding + border)

목차
  1. offsetHeight 예제 - 가시 높이
  2. offsetWidth 예제 - 가시 너비

 

offsetHeight 예제 - 가시 높이

 

<style>

#hz {

  height: 250px;

  width: 400px;

  padding: 10px;

  margin: 15px;

  border: 5px solid red;

  background-color: yellow;

}

</style>


<button onclick="homzzang()">클릭</button>


<div id="hz">

  <h1>홈짱닷컴 Homzzang.com</h1>

  Height: 250px<br>

  Width: 400px<br>

  padding: 10px<br>

  margin: 15px<br>

  border: 5px<br>  

</div>

<p id="demo"></p>


<script>

function homzzang() {

  var box = document.getElementById("hz");

  var txt = "offsetHeight = height + padding + border = " + box.offsetHeight + "px<br>";

  txt += "offsetWidth = width + padding + border : " + box.offsetWidth + "px";

  document.getElementById("demo").innerHTML = txt;

}

</script>

 

결과보기

 

offsetWidth 예제 - 가시 너비

 

<style>

#hz {

  height: 250px;

  width: 400px;

  padding: 10px;

  margin: 15px;

  border: 5px solid red;

  background-color: yellow;

}

</style>


<button onclick="homzzang()">클릭</button>


<div id="hz">

  <h1>홈짱닷컴 Homzzang.com</h1>

  Height: 250px<br>

  Width: 400px<br>

  padding: 10px<br>

  margin: 15px<br>

  border: 5px<br>  

</div>

<p id="demo"></p>


<script>

function homzzang() {

  var box = document.getElementById("hz");

  var txt = "offsetHeight = height + padding + border = " + box.offsetHeight + "px<br>";

  txt += "offsetWidth = width + padding + border : " + box.offsetWidth + "px";

  document.getElementById("demo").innerHTML = txt;

}

</script>

 

결과보기

  • offsetHeight = height + padding + border = 280px
  • offsetWidth = width + padding + border : 430px

 


분류 제목
DOM_Event_Object JS - StorageEvent 객체 - 윈도우창 저장영역 변경 (= 스토리지이벤트객체= 스토리지이벤트종류)
DOM_Event_Object JS - TouchEvent 객체 - 터치이벤트객체 (= 터치이벤트종류)
DOM_Event_Object JS - TransitionEvent 객체 - CSS 전환 실행 (= 트랜지션이벤트객체 = 트랜지션이벤트종류…
DOM_Event_Object JS - UiEvent 객체 - 유저인터페이스변환 (= 유아이이벤트객체 = 유저인터페이스이벤트종류 = 사용자…
DOM_Event_Object JS - WheelEvent 객체 - 마우스휠움직임 (= 휠이벤트객체)
API_Geolocation JS - coordinates -
API_Geolocation JS - position -
API_Geolocation JS - positionError -
API_Geolocation JS - positionOptions -
API_Geolocation JS - clearWatch() 메서드 -
API_Geolocation JS - getCurrentPosition() 메서드 -
API_Geolocation JS - watchPosition() 메서드 -
Window_History JS - history.length 속성 - history개수 (= 방문이력개수 = 방문주소개수 = 히스토리…
Window_History JS - history.back() 메서드 ★ - 이전페이지 가기
Window_History JS - history.forward() 메서드 - 다음페이지 가기
Window_History JS - history.go() 메서드 ★ - 특정페이지로 이동 (= history.go메서드 = 히스토리고…
DOM_HTMLCollection JS - item() 메서드 ★ - 지정 인덱스의 요소 반환 (= 특정 순번째 요소 반환)
DOM_HTMLCollection JS - length 속성 ★ - 요소개수 반환 (※ for반복문에 활용)
DOM_HTMLCollection JS - namedItem() 메서드 - 지정 id 또는 name 갖는 요소 반환
Window_Location JS - hash 속성 - URL앵커부분(= 샵부분 = 해시속성) 설정/반환
40/67
목록
찾아주셔서 감사합니다. Since 2012