通过 CSS 进行图像缩放:是否有 -moz-crisp-edges 的 webkit 替代品?
我有一张像素为 100x100 的图像。我想显示它两倍的大小,所以 200x200,我想通过 CSS 来完成它,而不是通过服务器(明确地)。
几年以来,所有浏览器都对图像进行了抗锯齿处理,而不是按像素缩放。
Mozilla 允许指定算法: image-rendering: -moz-crisp-edges; IE 也是如此:-ms-interpolation-mode:nearest-neighbor;
有任何已知的 webkit 替代品吗?
I have an image that is 100x100 in pixels. I want to show it twice the size, so 200x200 and I want to do it by CSS and (explicitly) not by the server.
Since a few years, images get anti-aliased by all browsers instead of doing a by-pixel scale.
Mozilla allows to specify the algorithm: image-rendering: -moz-crisp-edges;
So does IE: -ms-interpolation-mode: nearest-neighbor;
Any known webkit alternative?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
WebKit 现在支持 CSS 指令:
您可以使用 Chrome 和此页面上的最后一个图像来查看它的实际工作情况:
http://phrogz.net/tmp/canvas_image_zoom.html
该页面使用的规则是:
WebKit now supports the CSS directive:
You can see it working in action using Chrome and the last image on this page:
http://phrogz.net/tmp/canvas_image_zoom.html
The rules used on that page are:
不幸的是,WebKit 中似乎没有这个功能。请参阅最近的错误报告:
https://bugs.webkit.org/show_bug.cgi?id =40881
Unfortunately, it looks like this feature is absent in WebKit. See this recent bug report:
https://bugs.webkit.org/show_bug.cgi?id=40881
除了@Phrogz非常有用的答案之外,在阅读完本文后: https:// developer.mozilla.org/en-US/docs/CSS/image-rendering
似乎最好的 CSS 是这样的:
In addition to @Phrogz very useful answer and after reading this: https://developer.mozilla.org/en-US/docs/CSS/image-rendering
It seems like the best CSS would be this: