html name在css,CSS: *html #id_name

这篇博客讨论了CSS中针对IE6的星号HTML hack以及子选择器的使用。文章指出,*html#alertBox的语法在IE6中因浏览器bug导致生效,但不符合CSS规范,应添加空格使其合法。同时,#modalContainer>#alertBox是子选择器,IE6不支持,所以该规则会忽略,这在当前浏览器环境中产生了相反的效果。文章强调不应依赖这种行为,并提醒开发者注意代码的兼容性和冗余性。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

*html #alertBox {

height:100px;

}

That's a mistyped star-HTML. Star-HTML is a CSS hack usually used to target rules at IE6.

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.

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;

}

That's a child selector: it selects the alertBox when it's a direct child of modalContainer.

> 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.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值