jonas vermeulen
jonas vermeulen

Reputation: 1245

Responsive background image css media query

I have made some css to select the appropriate image for a device. However i don't know why it keeps displaying a bg970.png image on my retina mac pro 15 inch.

<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>

Upvotes: 0

Views: 2235

Answers (1)

andi
andi

Reputation: 6522

Your last statement is:

/* 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; }
}

but that seems to apply to any retina device, including your mac pro.

Upvotes: 2

Related Questions