修改你的iPhone 4媒体查询瞄准高密度像素显示器(视网膜iPhone4的=)
@media screen and (max-device-width: 640px), screen and (-webkit-min-device-pixel-ratio: 2) and (orientation:portrait) { ... }
没注意到你重新打开的问题与一个扩展,所以这里是一个重新设计的答案,目标是iPhone(3和4)和iPad。
击穿的你应该期望什么:
- 在常规的浏览器,你应该得到的
teal
背景颜色。
orange
在ipad上(风景)。 在iPad
black
(纵向)
red
在iPhone 4(纵向)
pink
在iPhone 4(横向)
- 在普通智能手机,比如机器人会在(横向)
purple
一个普通的智能手机(纵向)
CSS
body {
background-color:teal;
-webkit-transition: background-color 1000ms linear;
-moz-transition: background-color 1000ms linear;
-o-transition: background-color 1000ms linear;
-ms-transition: background-color 1000ms linear;
transition: background-color 1000ms linear;
}
/* iPads (portrait and landscape) ----------- */
@media only screen
and (min-device-width : 768px)
and (max-device-width : 1024px) {
body {
background-color:yellow;
}
}
/* iPads (landscape) ----------- */
@media only screen
and (min-device-width : 768px)
and (max-device-width : 1024px)
and (orientation : landscape) {
body {
background-color:orange;
}
}
/* iPads (portrait) ----------- */
@media only screen
and (min-device-width : 768px)
and (max-device-width : 1024px)
and (orientation : portrait) {
body {
background-color:black;
}
}
/* iPhone 4 - (portrait) ---------- */
@media
only screen and (-webkit-min-device-pixel-ratio : 2) and (orientation:portrait),
only screen and (min-device-pixel-ratio : 2) and (orientation:portrait){
body {
background-color:red;
}
}
/* iPhone 4 - (landscape) ---------- */
@media screen and (-webkit-min-device-pixel-ratio : 2) and (orientation:landscape), screen and (min-device-pixel-ratio : 2) and (orientation:landscape){
body {
background-color:pink;
}
}
/* Smartphones (landscape) ----------- */
@media only screen
and (min-width : 321px)
and (max-width: 480px) {
body {
background-color:green;
}
}
/* Smartphones (portrait) ----------- */
@media only screen
and (max-width : 320px) {
body {
background-color:purple;
}
}`<!-- language-all: lang-css -->
我重新格式化,在细腻article在发现在CSS-技巧,以满足一些iPhone4的特定位@media
查询,但总体来说这个媒体查询设定应涵盖的iPhone(3,4配有独立的媒体查询) iPad也是如此。
这是一个演示,你可以尝试在你的智能设备。
http://jsfiddle.net/andresilich/SpbC3/4/show/
而且你也可以尝试查询了在http://quirktools.com/screenfly/看他们如何叠起。但有一点,screenfly网站并没有区分iphone 3和iphone 4,因为普通浏览器跳过webkit
只有-webkit-min-device-pixel-ratio : 1.5
像素比例计数,因此您可以在实际设备中测试出更好的结果。
抱歉不工作,我仍然看到不同的css iPhone 3 – aki 2011-12-29 15:11:01
嗯,你清除你的缓存? – 2011-12-29 15:35:32
是的,我尝试了2 iphone 4,2 ipad和2 iphone 3 – aki 2011-12-29 15:46:53