첫째, 기본 요소 position
는 static
이며, 그 속성을 시각적으로 적용 할 예정되지 않은 top
, right
, bottom
, left
CSS에 어떤 조작을 의미한다.
relative
absolute
fixed
당신은 에 대해 자세히 알아볼 수 있습니다 : 당신이 top
속성을 변경하고자한다면
그래서, 당신은 또한 다음 값 중 하나와 요소 position
을 변경해야 CSS 위치 in Developer Mozilla
그래서 다음 코드를 사용하십시오. 다음 :
<h1 class="test">Hi!</h1>
<script>
x = document.getElementsByClassName('test')
x[0].style.position = 'relative'; // Changed the position property to relative.
x[0].style.top = '500px'; // Must be wrapped in quotes, and append the measurement unit in the value in this case the 'px'.
</script>
또한 CSS 측정에 대해 자세히 알아볼 수 있습니다 단위을 here
에