简体   繁体   English

针对视网膜显示进行了优化的精灵

[英]Sprites optimized for retina display

I'm building a responsive website so I've been reading about css sprites on mobile devices and iphones. 我正在建立一个响应式网站,所以我一直在阅读有关移动设备和iPhone上的CSS精灵的信息。 I found this article , I think it's the right tecnique but the explanation could've been better. 我找到了这篇文章 ,我认为这是正确的技术,但其解释本来可以更好。 I ended up with this: 我结束了这个:

http://jsfiddle.net/H9FcH/ http://jsfiddle.net/H9FcH/

Can somebody tell me if it looks ok on the iphone? 有人可以告诉我在iPhone上是否还可以吗? I'm not sure about that 50%. 我不确定那50%。 Also, does anyone have a better article? 另外,有人有更好的文章吗?

The background-size property you specify for Retine enabled devices, should contain the size of the non-Retina sprite , ie, half the width and half the height of the Retina sprite. 您为启用Retine的设备指定的background-size属性应包含非Retina精灵的大小,即Retina精灵的宽度和高度的一半。 It should be the size of the total sprite, so not just the size of a single icon within the sprite. 它应该是整个精灵的大小,而不只是精灵中单个图标的大小。

Updated Fiddle: http://jsfiddle.net/jhogervorst/qr5fs/2/ 更新的小提琴: http : //jsfiddle.net/jhogervorst/qr5fs/2/

Screenshot (Retina): http://i.stack.imgur.com/sIDnE.png 屏幕截图(视网膜): http : //i.stack.imgur.com/sIDnE.png

CSS: CSS:

@media only screen and (-webkit-min-device-pixel-ratio: 1.5),
       only screen and (min--moz-device-pixel-ratio: 1.5),
       only screen and (min-resolution: 240dpi) {
        .action {
            background-image: url(http://dl.dropbox.com/u/13823768/masonry/img/test-sprite2x.png);
            -moz-background-size: 153px 64px;
            -o-background-size: 153px 64px;
            -webkit-background-size: 153px 64px;
            background-size: 153px 64px;
        }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM