Understanding Retina device CSS Media queries

可紊 提交于 2019-12-03 17:35:19

As long as there is some form of scaling taking place, like when you declare

<meta name="viewport" content="width=..."> (for android/ios/blackberry/WP8)

or

@ms-viewport {width: ... ;} (for non-WP8 IE10)

or ... even if you declare nothing most mobile devices will by default automatically scale such that viewport width=980px

then all CSS dimensions you declare with 'px' will exist in the same proportion to their viewport regardless of differences between their physical DPI/PPI

this means you shouldn't have to change a single thing about your style class except the background image's URL when the media query matches a high res device:

@media only screen and (-moz-min-device-pixel-ratio: 1.5),
only screen and (-o-min-device-pixel-ratio: 3/2),
only screen and (-webkit-min-device-pixel-ratio: 1.5),
only screen and (min-device-pixel-ratio: 1.5),
only screen and (min-resolution: 144dpi) {
    .side-nav .arrow { 
         background-image:url(../images/arrow-nav@2x.png);
     }
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!