Computer >> 컴퓨터 >  >> 프로그램 작성 >> HTML

HTML 창 screenTop 속성

<시간/>

HTML Window screenTop 속성은 화면을 기준으로 창의 수직 좌표를 반환합니다. 파이어폭스 브라우저에서는 지원하지 않습니다.

구문

다음은 구문입니다 -

window.screenTop

HTML 창 screenTop 속성의 예를 살펴보겠습니다 -

예시

<!DOCTYPE html>
<html>
<style>
   body {
      color: #000;
      height: 100vh;
      background-color: #8BC6EC;
      background-image: linear-gradient(135deg, #8BC6EC 0%, #9599E2 100%);
      text-align: center;
   }
   .btn {
      background: #db133a;
      border: none;
      height: 2rem;
      border-radius: 2px;
      width: 40%;
      display: block;
      color: #fff;
      outline: none;
      cursor: pointer;
      margin: 1rem auto;
   }
   .show {
      font-size: 1.2rem;
   }
</style>
<body>
<h1>HTML Window screenTop Property Demo</h1>
<button onclick="display()" class="btn">Show screenTop value</button>
<div class="show"></div>
<script>
   function display() {
      document.querySelector('.show').innerHTML = 'The vertical coordinate of the window relative to the screen is: ' + window.screenTop + 'px';
   }
</script>
</body>
</html>

출력

HTML 창 screenTop 속성

'화면 상단 값 표시를 클릭합니다. " 버튼을 눌러 화면을 기준으로 창의 수직 좌표를 표시합니다.

HTML 창 screenTop 속성