📅  最后修改于: 2023-12-03 15:31:15.918000             🧑  作者: Mango
在 HTML 中,通过 window.screen.pixelDepth
或 screen.pixelDepth
属性获取当前屏幕的颜色深度,即每个像素点的颜色位数。在计算机图形学中,一般用 bit 表示颜色位数。
window.screen.pixelDepth
screen.pixelDepth
返回当前屏幕的颜色位数,可能的值有:
<!DOCTYPE html>
<html>
<head>
<title>屏幕颜色位数示例</title>
</head>
<body>
<p>浏览器窗口的颜色位数为 <span id="color-depth"></span></p>
<script>
var colorDepth = window.screen.pixelDepth;
document.getElementById("color-depth").innerHTML = colorDepth + " 位";
</script>
</body>
</html>
该示例会在页面中展示当前浏览器窗口的颜色位数。