HTML 螢幕 availHeight 屬性


HTML 螢幕 availHeight 屬性返回使用者螢幕的可用高度,這意味著它不包括瀏覽器的介面特徵。

語法

以下是語法 -

screen.availHeight

示例

讓我們看一個 HTML 螢幕 availHeight 屬性的示例

即時演示

<!DOCTYPE html>
<html>
<style>
   body {
      color: #000;
      height: 100vh;
      background-color: #FBAB7E;
      background-image: linear-gradient(62deg, #FBAB7E 0%, #F7CE68 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;
      margin: 1rem auto;
      font-weight: bold;
      font-family: sans-serif;
   }
</style>
<body>
<h1>HTML screen availHeight Property</h1>
<button class="btn" onclick="get()">Show availHeight Value</button>
<div class="show"></div>
<script>
   function get() {
      document.querySelector(".show").innerHTML = "Available Height is " + screen.availHeight + " px";
   }
</script>
</body>
</html>

輸出

單擊“顯示 availHeight 值”按鈕以顯示 availHeight 屬性的值 -

更新於: 16-Feb-2021

138 次瀏覽

開啟你的職業生涯

完成課程獲得認證

開始學習
廣告