so I've read a few stuff about retina graphics for website and since most of my images can be at 2X, I'd guess: Why not, while using @media queries
.
However, all I could find about sizing, was that you should specify dimensions, but I'm wondering: What about background images using background-size:cover
!
As in:
div {
background-image: url('../images/foo.png');
background-size:cover;
height:100%;
width:100%;
// max-size:1920px by X
}
@media
only screen and (-webkit-min-device-pixel-ratio: 2) and (min-width: 1921px),
only screen and ( min--moz-device-pixel-ratio: 2) and (min-width: 1921px),
only screen and ( -o-min-device-pixel-ratio: 2/1) and (min-width: 1921px),
only screen and ( min-device-pixel-ratio: 2) and (min-width: 1921px),
only screen and ( min-resolution: 192dpi) and (min-width: 1921px),
only screen and ( min-resolution: 2dppx) and (min-width: 1921px) {
div {
background-image: url('../images/foo@2x.png');
background-size:cover;
height:100%;
width:100%;
// min-size:1921px by X
}
}
Second question, if I may: What if you've an image of max approximately 2400x1380, but the visitors machine has a maximum resolution of 2880x2160, as in the Macbook 15" retina - thus not being able to server the complete @2X experience - Serve @2x no matter what, or serve a regular, max 1920px image?
And third, in regard to 1 & 2 - While using :cover
, you're not specifying dimensions, thus not knowing the minimum of the @2x image. with that in mind, is there a way to say "For retina images and using :cover
, you're image should be at least this by this dimensions" ?
Thanks!