JavaScript

[DOM_Style] JS - position 속성 - 위치기준대상지정 (= 위치속성 = 포지션속성 = position속성, 상속 X, IE7) ※ 화면 정중앙 배치/정렬

position 예제

 

<style> 

#hz {

  border: 1px solid silver;

  background-color: tomato;

  width: 300px;

  height: 200px;

  position: relative;

  top: 20px;

}

</style>


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


<div id="hz">

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

</div>


<script>

function homzzang() {

  document.getElementById("hz").style.position = "absolute";

}

</script>

 

 


position 예제 - 화면 정중앙 배치/정렬

 

<style>
div {width:200px; border:1px solid red;}

</div>

 

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

 

<script> 

var div = document.getElementsByTagName('div');

div[0].style.position = 'absolute';

div[0].style.left = '50%';

div[0].style.top = '50%';

div[0].style.transform = "translate(-50%, -50%)";

</script>

 

결과보기



분류 제목
DOM_Style JS - left 속성 - 왼쪽기준 (= left속성 = 좌측기준 = 레프트속성, 상속 X)
DOM_Style JS - letterSpacing 속성 ★ - 글자 간격 반환/설정 ( 텍스트사이띄우기 = 문자 간격 = 글…
DOM_Style JS - lineHeight 속성 ★ - 텍스트라인높이 (= line-height속성 = 텍스트줄높이 = 글…
DOM_Style JS - listStyle -
DOM_Style JS - listStyleImage -
DOM_Style JS - listStylePosition -
DOM_Style JS - listStyleType 속성 - 리스트 마커 모양 (= listStyleType속성 / 리스트스타…
DOM_Style JS - margin -
DOM_Style JS - marginBottom -
DOM_Style JS - marginLeft -
DOM_Style JS - marginRight -
DOM_Style JS - marginTop -
DOM_Style JS - maxHeight -
DOM_Style JS - maxWidth 속성 - 가로최대너비 (= 가로최대길이)
DOM_Style JS - minHeight -
8/13
목록
 홈  PC버전 로그인 일본어
그누앞단언어
그누뒷단언어
그외코딩언어
그누보드
제작의뢰
Q&A
커뮤니티 2
웹유틸
회원센터
홈짱닷컴 PC버전 로그인