HTML Screen colorDepth 属性
htmlfront end technologyweb development更新于 2024/5/21 16:44:17
HTML Screen colorDepth 属性返回用于显示图像的调色板的位深度(以每像素位数为单位)。
语法
以下是语法 −
screen.colorDepth
示例
让我们看一个 HTML Screen colorDepth 属性的示例 −
<!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 colorDepth Property</h1>
<button class="btn" onclick="get()">Show color depth</button>
<div class="show"></div>
<script>
function get() {
document.querySelector(".show").innerHTML = "Color Depth is " + screen.colorDepth + " bits per pixel";
}
</script>
</body>
</html>
输出

点击"显示色彩深度"按钮显示屏幕的色彩深度。

相关文章
有用资源
html 参考教程 - 该教程包含有关 html 的更多信息:https://www.cainiaomax.com/html/

