像素相关概念总结

332 阅读1分钟

一、设备像素:是组成图像的基本元素,是点的概念。

二、分辨率:横向设备像素*纵向设备像素。

console.log(window.screen.width * window.devicePixelRatio);
console.log(window.screen.height * window.devicePixelRatio);

三、设备独立像素(CSS像素):由程序控制,并可以转化为设备物理像素的虚拟像素。

console.log(window.screen.height);

四、设备像素比:设备像素/设备独立像素(某一方向上)

console.log(window.devicePixelRatio);

五、每英寸像素数(PPI):像素密度,即每英寸内设备像素数目。