我已经制作了一些CSS来为设备选择合适的图像。但是我不知道为什么它一直在15英寸的视网膜Mac pro上显示bg970.png图像。
<style>
/* default screen, non-retina */
/* Smartphones (portrait and landscape) ----------- */
@media only screen
and (min-device-width : 320px)
and (max-device-width : 480px) {
/* Styles */
body{
background: url("img/bg970.png") no-repeat fixed; }
}
/* Smartphones (landscape) ----------- */
@media only screen
and (min-width : 321px) {
/* Styles */
body{ background: url("img/bg970.png") no-repeat fixed; }
}
/* Smartphones (portrait) ----------- */
@media only screen
and (max-width : 320px) {
/* Styles */
body{ background: url("img/bg970.png") no-repeat fixed; }
}
/* iPads (portrait and landscape) ----------- */
@media only screen
and (min-device-width : 768px)
and (max-device-width : 1024px) {
/* Styles */
body{ background: url("img/bg970.png") no-repeat fixed; }
}
/* iPads (landscape) ----------- */
@media only screen
and (min-device-width : 768px)
and (max-device-width : 1024px)
and (orientation : landscape) {
/* Styles */
body{ background: url("img/bg970.png") no-repeat fixed; }
}
/* iPads (portrait) ----------- */
@media only screen
and (min-device-width : 768px)
and (max-device-width : 1024px)
and (orientation : portrait) {
/* Styles */
body{ background: url("img/bg970.png") no-repeat fixed; }
}
/* Desktops and laptops ----------- */
@media only screen
and (min-width : 1224px) {
/* Styles */
body{ background: url("img/bg1224.png") no-repeat fixed; }
}
/* Large screens ----------- */
@media only screen
and (min-width : 1824px) {
/* Styles */
body{ background: url("img/bg1824.png") no-repeat fixed; }
}
/* iPhone 4 ----------- */
@media
only screen and (-webkit-min-device-pixel-ratio : 1.5),
only screen and (min-device-pixel-ratio : 1.5) {
/* Styles */
body{ background: url("img/bg970.png") no-repeat fixed; }
}
</style>
答案 0 :(得分:2)
你的上一个陈述是:
/* iPhone 4 ----------- */
@media
only screen and (-webkit-min-device-pixel-ratio : 1.5),
only screen and (min-device-pixel-ratio : 1.5) {
/* Styles */
body{ background: url("img/bg970.png") no-repeat fixed; }
}
但这似乎适用于任何视网膜设备,包括你的mac pro。