CSS:* html #id_name [英] CSS: *html #id_name
问题描述
我有这个代码
*html #alertBox {
height:100px;
}
#modalContainer > #alertBox {
position:fixed;
}
这是css支持的,我发现这个代码在其他网站忘记了链接)
is this supported by css, i found this code in some other site(I forgot the link)
推荐答案
*html #alertBox {
height:100px;
}
这是一个错误的星形HTML。 Star-HTML是通常用于在IE6上定位规则的CSS黑客。
That's a mistyped star-HTML. Star-HTML is a CSS hack usually used to target rules at IE6.
规则中的star-HTML前缀不应该匹配任何内容,因为没有元素 html
)上方的 *
)。但是由于浏览器中的错误,它会在IE上到版本6。
The star-HTML prefix in a rule shouldn't match anything, because there is no element (*
) above the root element (html
). But it does in IE up to version 6 due to bugs in that browser.
然而,为了这是一个有效的规则,在<$ c之间必须有一个空格$ c> * 和 html
。当前代码是无效的CSS:验证器将抱怨和浏览器可能会做出意想不到的事情。因为它发生,在当前的浏览器的作品没有区别:IE6-7允许无空间语法,其他人忽略整个规则。但你不应该真正依赖这个。
However for this to be a valid rule, there must be a space between the *
and the html
. The current code is invalid CSS: the validator will complain and browsers might do unexpected things with it. As it happens, in the current crop of browsers there is no difference: IE6-7 allows the spaceless syntax, the others ignore the whole rule. But you shouldn't really rely on that.
#modalContainer > #alertBox {
position:fixed;
}
这是一个子选择器:当它是一个直接的孩子modalContainer 。
That's a child selector: it selects the alertBox when it's a direct child of modalContainer.
>
是IE6根本不理解的,所以结果是定位规则所有浏览器,除了IE6(不支持 position:fixed
)。这使得它或多或少是与star-HTML hack相反的。显然,它被用于这里的目的,否则选择器,包括两个唯一的ID,是相当冗余的。
>
is something IE6 doesn't understand at all, so the consequence is to target the rule at all browsers except IE6 (which doesn't support position: fixed
). This makes it more-or-less the opposite of the star-HTML hack. Clearly it is being used for the purpose here, as otherwise the selector, including two unique IDs, is quite redundant.
这篇关于CSS:* html #id_name的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!