gpt4 book ai didi

css - 应用 * :first-child +html in same CSS file with different attributes

转载 作者:行者123 更新时间:2023-11-28 18:31:35 25 4
gpt4 key购买 nike

我有一个通用的 CSS 文件,有两个页面引用了它。

引用此通用 CSS 的页面需要以下 CSS,

*:first-child + html .rich-tabpanel {
margin-left:-13px; // Note : Its 13px here
}

引用此通用 CSS 的其他页面需要以下 CSS,

*:first-child + html .rich-tabpanel {
margin-left: 0px; //Note : Its 0px here
}

HTML代码如下,

<table class="rich-tabpanel">

我只在 IE7 中遇到这个问题,它没有使用下面的代码(我不知道为什么),

.ie7 .rich-tabpanel {
margin-left: 13px; //OR 0px depending on the page
}

所以,我删除了上面的代码,只使用了 *:first-child + html .rich-tabpanel 代码

如何在同一个通用 CSS 文件中为 rich-tabpanel 属性设置两个不同的 margin-left 属性?

最佳答案

从那一刻起 *:first-child +html .rich-tabpanel 是一个 hack,它是 specificity未知。 .ie7 .rich-tabpanel 具有特殊性 0020,因此黑客可能具有高于它的特殊性。将选择器 .ie7 .rich-tabpanel 更改为 html .ie7 .rich-tabpanel,这会更改特性,然后应用规则。我不保证这是一个特殊性问题,但在任何情况下更改选择器都是可行的。

演示: http://jsfiddle.net/xWX2R/1/

无论如何,我建议你使用conditional comments比 Internet Explorer 的黑客攻击。

关于css - 应用 * :first-child +html in same CSS file with different attributes,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14120559/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com