在我的 css 类中使用 Zoom:1 可以吗?

发布于 2024-08-31 18:41:25 字数 216 浏览 5 评论 0原文

每当我发现 IE 显示我的网站很奇怪(与 chrome 和 firefox 不同)时,我会尝试在 css 类中放置一个 zoom:1 来显示奇怪的部分。很多时候这可以解决问题并使其看起来与其他浏览器一致。

使用zoom:1有问题吗?我知道我的 CSS 无法验证,但是如果我过于依赖使用 zoom:1,是否会出现任何现实问题?

Whenever I find IE is displaying my website weird (different from chrome and firefox), I try putting a zoom:1 in the css class for the part that is being displayed weird. A lot of the time this fixes the problem and makes it look consistent with the other browsers.

Is it a problem to use zoom:1? I know my CSS won't validate, but are there any real world problems that can arise if I rely too much on using zoom:1?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

夏末染殇 2024-09-07 18:41:25

您遇到的问题是 IE hasLayout 问题。 这里是一篇很好的文章和概述,介绍了哪些属性也会在 IE 中触发“having Layout”。

据我所知,zoom: 1 没有任何副作用,只是它不符合 W3C 标准。我很确定我自己在一些项目中使用它。

然而,当然,有一天 zoom 成为真正的 CSS 属性的可能性很小 - 或者在另一种专有环境中使用,例如在 iPad 或其他设备上 - 这可能会导致事情崩溃。

缩放不是一个真正干净的解决方案。如果可能的话,最好以本文中概述的其他方式提供元素“布局”。

The problem you are fighting with this is the IE hasLayout issue. Here is a good article and overview on which properties also trigger "having Layout" in IE.

I know of no side-effects to zoom: 1 except that it's not W3C valid. I'm pretty sure I'm using it myself in some projects.

However, there is of course the remote chance that zoom becomes a real CSS property one day - or gets used in another proprietary context like on the iPad or whatever - which could lead to things breaking.

A really clean solution, zoom is not. If at all possible, it's a good idea to give the element "Layout" in some other way as outlined in the article.

我很OK 2024-09-07 18:41:25

相反,使用 Zoom:1 也有明显的缺点,即使在 IE 中也是如此。通常,我只将它包含在仅限 IE 的样式表中,但即使在过去的几天里,我也一直在努力解决一些布局问题,因为我选择使用 *{zoom:1;}

——要点 ——在有限的情况下使用它基础。如果只关心IE7+,可以使用min-height: 1%,与触发hasLayout效果相同

To the contrary, there are definitive downsides to using zoom:1, even in IE. Usually, I only include it in IE-only stylesheets, but even in the past few days I've wrestled with some layout issues because I opted to use *{zoom:1;}

-- the takeaway -- use it on a limited basis. If you only care about IE7+, you can use min-height: 1%, which has the same effect of triggering hasLayout

青瓷清茶倾城歌 2024-09-07 18:41:25

截至 2012 年 11 月,zoom 更有可能有一天成为有效的 CSS,尽管在上述上下文中使用它似乎不会产生任何负面副作用。

请参阅:http://dev.w3.org/csswg/css-device-adapt/ http://www.w3.org/TR/css-device - 适应/

As of November 2012, it is ever more likely that zoom will someday become valid CSS, although it seems that using it in the above context should not have any negative side-effects.

See: http://dev.w3.org/csswg/css-device-adapt/ or http://www.w3.org/TR/css-device-adapt/

梦在深巷 2024-09-07 18:41:25

仅 IE 支持缩放,目前不支持。未来可能会有一个名为“zoom”的属性,它可能会把事情搞砸,但由于广泛使用,这种情况不太可能发生。

zoom is only supported by IE, so not at the moment. Potentially there could be a future property called zoom which could mess things up, but this is unlikely due to widespread usage.

铃予 2024-09-07 18:41:25

display: inline-block; 做同样的事情,但是是标准代码。

罕见的情况下,它会产生问题,您可以

display: block !important; /* or inline, etc. */ 
display: inline-block; /* in this order */

将其仅发送到它有用的旧版 Internet Explorer。

display: inline-block; does the same thing, but is standard code.

In the rare case it creates a problem, you can use

display: block !important; /* or inline, etc. */ 
display: inline-block; /* in this order */

to send it only to the ancient versions of Internet Explorer for which it's useful.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文