开发者

Scaling up image with pixels in HTML/CSS?

In my DIV I want to show a specific part of an image (that part is 8x8 pixels) (on the orginal image to view tose 8x8pixels you would have to do background-position: -8px -8px;), but enlarged with the "pixels saved". So you get http://piclair.com/86m3r when scaled up instead of http://piclair.com/lxn12

If anyone now how to achieve this, please tell me. I really need to开发者_C百科 solve this problem!


Image scaling is handled by different browsers in different ways, and there's no official way to specify how these images are scaled.

However, Firefox 3.6 and above will let you specify image-rendering in CSS. You can enable it with this CSS:

img {
    image-rendering: -moz-crisp-edges;
}

See the article on image-rendering on the Mozilla website for more details — it also applies to "background-images of any element", which sounds like what you're after.


A more complete list of CSS image interpolation properties can be found here: http://www.danolsavsky.com/article-images-interpolation-browser-rendering-and-css-resizing.html

Firefox:

image-rendering: optimizeSpeed;

image-rendering: optimizeQuality;

image-rendering: -moz-crisp-edges;

Opera:

image-rendering: -o-crisp-edges;

Chrome:

image-rendering: -webkit-optimize-contrast;

IE 8+:

-ms-interpolation-mode: nearest-neighbor;

W3C standard:

image-rendering: optimize-contrast;

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜