CSS zoom not blurry but pixelated

2020-07-16 03:09发布

I'd like to use zoom property in CSS for images but would not like to have a blurry effect to enlarged images but rather pixelated. How can I achieve this?

edit: if neccesary, it is ok to use other properties or other languages.

标签: css zoom
2条回答
爱情/是我丢掉的垃圾
2楼-- · 2020-07-16 03:40

You might want to try a lightweight jQuery plugin called Zoomoz. The settings include easing and native animation too.

查看更多
做自己的国王
3楼-- · 2020-07-16 03:51

You cannot (currently) use upscaling and specify that the browser should use nearest-neighbor zooming, neither with HTML images, upsized HTML5 canvases, using drawImage() on a canvas to draw the image larger, nor zooming up images on SVG.

Here's a solution (written for this related question) showing how to 'zoom' an image using nearest-neighbor pixelation by re-creating the image as rectangles in SVG: http://phrogz.net/tmp/canvas_image_zoom_svg.xhtml

Here's another solution showing how to achieve this same effect using HTML5 Canvas (drawing rectangles on the canvas for the zoom):
http://phrogz.net/tmp/canvas_image_zoom.html

查看更多
登录 后发表回答