CSS dppx详解

每像素包含点的数量(dots per pixel)

普通屏幕通常包含96dpi,一般将2倍于此的屏幕称之为高分屏,即大于等于192dpi的屏幕,比如Mac视网膜屏就达到了192dpi(即2dppx),打印时一般会需要更大的dpi;

1dppx = 96dpi

1dpi ≈ 0.39dpcm

1dpcm ≈ 2.54dpi

1in = 2.54cm = 25.4 mm = 101.6q = 72pt = 6pc = 96px

 

示例代码:

@media screen and (min-resolution: 2dppx) { ... }
@media screen and (min-resolution: 1dppx) and (max-resolution: 1.9dppx) { ... }

  

演示代码:

<!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta charset="utf-8" />
<title>CSS dppx详解-CSS教程</title>
<meta name="author" content="Joy Du(飘零雾雨), dooyoe@gmail.com, www.doyoe.com" />
<style>
@media screen and (min-resolution: 2dppx) {
    .normal{display:none;}
}
@media screen and (min-resolution: 1dppx) {
    .retina{display:none;}
}
</style>
</head>
<body>
<p class="retina">视网膜屏</p>
<p class="normal">普通屏</p>
</body>
</html>
    

 

posted @ 2021-04-12 15:30  deajax  阅读(272)  评论(0编辑  收藏  举报