HTML 螢幕 pixelDepth 屬性
HTML Screen pixelDepth 屬性返回訪問者的螢幕顏色解析度。
語法
語法如下 −
screen.pixelDepth
示例
讓我們看一個 HTML Screen pixelDepth 屬性示例 −
<!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 pixelDepth Property</h1>
<button class="btn" onclick="get()">Show pixel depth</button>
<div class="show"></div>
<script>
function get() {
document.querySelector(".show").innerHTML = "Color Resolution is " + screen.pixelDepth + " bits per pixel";
}
</script>
</body>
</html>輸出
![]()
單擊“顯示畫素深度”按鈕以顯示訪問者的螢幕顏色解析度。
![]()
廣告
資料結構
網路
RDBMS
作業系統
Java
iOS
HTML
CSS
安卓
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP