CSS3 变换:IE 中的缩放
我想使用CSS3属性transform:scale。
div
{
transform: scale(0.5,0.5);
}
有没有办法在 Internet Explorer 8 及更低版本中模仿这个? 可能是带有 filter
或 Javascript 解决方案的东西?
我在网上搜索过,没有任何结果。
非常感谢,文森特
I would like to use the CSS3 property transform:scale.
div
{
transform: scale(0.5,0.5);
}
Is there a way to imitate this in Internet Explorer 8 and lower?
May be something with filter
or a Javascript solution?
I've searched the web without any result.
Thanks a lot, Vincent
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
IE9 支持转换:
对于其他版本的 IE,有一个复杂的语法。像这样的东西:
看这里 了解更多信息。
IE9 supports transform:
For other versions of IE, there's a complex syntax. Something like this:
Look here for more info.
不,IE8 及更早版本不支持标准
transform
样式。不过IE9确实支持它。您可以尝试使用
filter
样式解决方案,但它们会很混乱。但对于您在问题中描述的简单情况(基本上是简单的缩小),您可以使用 IE 专有的
zoom
属性。由于它是非标准的,所以
zoom
最常见的用法是与zoom:1
一起使用,它用于修复许多 IE 的布局故障(特别是在 IE6 和 IE7 中) 。但它也确实可以进行实际缩放,您可以使用zoom:0.5
来实现您想要的效果。使用
zoom
的好处是,它可以像任何其他普通 CSS 属性一样在 IE 中工作(filter
替代方案有一些严重的渲染怪癖,您需要了解)。使用
zoom
的唯一缺点是您需要在 IE9 或更高版本中禁用它,否则它会与您的transform
样式相互作用并产生一些不需要的效果。我不是一个普遍支持使用 CSS hack 的人,但你可以使用/9
hack (记录在此处)使其仅影响 IE8 及更早版本,这意味着您可以指定两个transform
和zoom
在同一个样式表中,如下所示:否则,您需要使用条件注释来确定是否使用它。
显然,如果您想做比简单比例尺更复杂的事情,那么
zoom
将不适合,但对于像您问题中的简单情况,它将是完美的。No, IE8 and earlier do not support the standard
transform
style. IE9 does support it though.There are solutions you could try using the
filter
style, but they will be messy.But for the simple case that you're describing in the question (basically a simple scaling down), you could use the IE-proprietary
zoom
property.Since it's non-standard, the most common use of
zoom
is withzoom:1
, which is used to fix a number of IE's layout glitches (particlarly in IE6 and IE7). But it does also do actual zooming as well, and you can usezoom:0.5
to achieve the effect you're looking for.The good thing about using
zoom
is that it is works in IE like any other normal CSS property (thefilter
alternative has some serious rendering quirks that you need to know about).The only down-side of using
zoom
is that you'd need to disable it in IE9 or later, otherwise it'll interract with yourtransform
style and have some unwanted effects. I'm not one to generally support the use of CSS hacks, but you could use the/9
hack (documented here) to make it only affect IE8 and earlier, meaning you can specify both thetransform
and thezoom
in the same stylesheet, like so:Otherwise you'd need to use conditional comments to determine whether to use it.
Obviously if you want to do anything more complex than a simple proportional scale, then
zoom
won't be suitable, but for a simple case like the one in your question it will be perfect.http://msdn.microsoft.com/en- us/library/ms533014(v=vs.85).aspx
虽然 IE 中的滤镜不太好用,而且它们并不总是与其他 css 效果结合使用......
但是 IE 9 支持规模
https://developer.mozilla.org/en/CSS/transform
http://msdn.microsoft.com/en-us/library/ms533014(v=vs.85).aspx
although, filters in IE isn't easy to use and they are not always combined with other css effects....
but IE 9 support scale
https://developer.mozilla.org/en/CSS/transform
试试这个:
https://github.com/pbakaus/transformie
Try this:
https://github.com/pbakaus/transformie