* CSS黑客的范围是什么? [英] What is the scope of the * CSS hack?

查看:100
本文介绍了* CSS黑客的范围是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在寻找一个黑客来解决我有一个CSS问题。我已使用一个为Internet Explorer创建自定义规则。

I have been looking at a hack to solve a CSS problem I have. I haved used one to create a custom rule for Internet Explorer.

margin-top:45px;
*margin-top:0px;

这个黑客攻击是否适用于所有的IE浏览器?

Does this hack apply to all IE browsers? Does this hack appear in any versions of Firefox or Safari?

推荐答案

这适用于IE7及以下版本。但请注意,这不是有效的CSS ,它可以随时中断。有关各种CSS黑客及其影响的浏览器的更全面列表,请参见此处

This applies to IE7 and below. But be aware that this is not valid CSS, and it could break at any time. See here for a more comprehensive list of the various CSS hacks and which browsers they affect.


虽然Internet Explorer 7在属性名称带有下划线或连字符前缀时修正了其行为,但其他非字母数字字符前缀按照在IE6中的方式处理。因此,如果您在属性名称之前添加非字母数字字符(例如星号(*)),该属性将应用于IE而不是其他浏览器。与连字符和下划线方法不同,CSS规范不对星号作为前缀保留,因此使用此黑客可能会导致CSS规范发展时出现意外行为。

Although Internet Explorer 7 corrected its behavior when a property name is prefixed with an underscore or a hyphen, other non-alphanumeric character prefixes are treated as they were in IE6. Therefore, if you add a non-alphanumeric character such as an asterisk (*) immediately before a property name, the property will be applied in IE and not in other browsers. Unlike with the hyphen and underscore method, the CSS specification makes no reservations for the asterisk as a prefix, so use of this hack could result in unexpected behavior as the CSS specifications evolve.

我强烈建议你重新考虑你是否真的需要这个黑客,如果没有更好的方法来做你想要的。

I'd strongly recommend reconsidering whether you really need this hack, and if there isn't a better way to do what you want.

这篇关于* CSS黑客的范围是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆