css - Wondering on how to serve different image backgrounds with media queries (especially for retina displays) -
i'm doing css code website uses full cover background , want serve media queries several devices different resolutions.
i've figured out how iphones , ipads doing this:
@media screen , (min-device-width:320px) , (max-device-width:480px) , (-webkit-min-device-pixel-ratio:1) { /* iphone 2g/3g/3gs */ } @media screen , (min-device-width:640px) , (max-device-width:960px) , (-webkit-min-device-pixel-ratio:2) { /* iphone 4/4s */ } @media screen , (min-device-width:560px) , (max-device-width:1136px) , (-webkit-min-device-pixel-ratio:2) { /* iphone 5 */ } @media screen , (min-device-width:768px) , (max-device-width:1024px) , (-webkit-min-device-pixel-ratio:1) { /* ipad 1/2 , ipad mini */ } @media screen , (min-device-width:1536px) , (max-device-width:2048px) , (-webkit-min-device-pixel-ratio:2) { /* ipad 3/4 */ }
and desktop screens:
@media screen , (min-device-width:1280px), screen , (min-device-width:1366px), screen , (min-device-width:1440px) { /* regular desktop resolutions */ } @media screen , (min-device-width:1680px), screen , (min-device-width:1920px) { /* larger desktop resolutions, hd screens */ }
since purpose of media queries satisfy only full cover background using css rule in each @media
(with different images, obviously, reduce server load , display friendly background considering specs between devices)...
html { background:url("image.jpg") no-repeat center center fixed; -webkit-background-size:cover; -moz-background-size:cover; -o-background-size:cover; background-size:cover;}
i have doubts doing retina screens (especially macbook pro retina, 13inch , 15inch models).
i guess that, using same logic above, should this:
@media screen , (min-device-width:2560px) , (min--moz-device-pixel-ratio: 2), screen , (min-device-width:2560px) , (-o-min-device-pixel-ratio: 2/1), screen , (min-device-width:2560px) , (-webkit-min-device-pixel-ratio: 2), screen , (min-device-width:2560px) , (min-device-pixel-ratio: 2) { /* 13inch model */ } @media screen , (min-device-width:2880px) , (min--moz-device-pixel-ratio: 2), screen , (min-device-width:2880px) , (-o-min-device-pixel-ratio: 2/1), screen , (min-device-width:2880px) , (-webkit-min-device-pixel-ratio: 2), screen , (min-device-width:2880px) , (min-device-pixel-ratio: 2) { /* 15inch model */ }
so... hope works in way.
also, give me advice on improving this. main idea each display resolution , device, different image served, avoid overloading both server , client side (in case, browser).
this old, maybe these links help?
Comments
Post a Comment