상단 위치를 설정하려면 상단 JavaScript의 속성. 다음 코드를 실행하여 JavaScript로 div의 상단 위치를 설정할 수 있습니다 -
예시
<!DOCTYPE html>
<html>
<head>
<style>
#myID {
position: absolute;
}
</style>
</head>
<body>
<button onclick="display()">Set Top Position</button>
<div id = "myID">
This is demo text! This is demo text!
</div>
<script>
function display() {
document.getElementById("myID").style.top = "100px";
}
</script>
</body>
</html>