Firefox :: - moz选择选择器bug(?)有没有解决方法? [英] Firefox ::-moz-selection selector bug(?) is there a workaround?
问题描述
我在一个网站上有大量的颜色样式,大约250行的CSS定义7种颜色方案之一,所以重要的是,我保持各种颜色规则尽可能分组。
I'm working on a site that has a large number of color styles, around 250 lines of CSS to define one of 7 color schemes, so it's important that I keep the various color rules grouped as best I can.
当我尝试并堆栈与弃用的CSS3 :: selection
pseudo相关的选择器时,Firefox 4的最新RC行为表现不佳元件。
The newest RC of Firefox 4 is behaving badly when I try and stack selectors relating to the deprecated CSS3 ::selection
pseudo element.
这样做:
.green ::-moz-selection {
/* 'Pure Hue' Color */
background-color: #62BA21;
color: white;
}
但是一旦我尝试和webkit的选择器共享规则就会中断。
But once I try and share the rule with the selector for webkit it breaks.
不适用于FireFox:
Does not work for FireFox:
.green ::selection, .green ::-moz-selection {
/* 'Pure Hue' Color */
background-color: #62BA21;
color: white;
}
我知道他们可能没有解决错误,因为 :: selection
不再存在于工作草案中,但我更喜欢如果我没有膨胀我的CSS超过它已经是这个怪癖。
I understand they might not be addressing the bug since ::selection
is no longer present in the working draft, but I'd prefer if I didn't have to bloat my CSS any more than it already is for this quirk.
推荐答案
Firefox似乎根本不理解 :: selection
(因此需要供应商前缀< c $ c> :: moz-selection ),因此它会忽略遇到无法识别的选择器的整个规则根据规范。
Firefox appears to simply not understand ::selection
(hence necessitating the vendor-prefixed ::-moz-selection
), so it ignores the entire rule on encountering an unrecognized selector per the spec.
浏览器不了解一个或多个选择器的常见解决方法组是分割/复制规则集:
The common workaround for a browser not understanding one or more selectors in a group is to split/duplicate the rule set:
/* Firefox sees this */
.green ::-moz-selection {
background-color: #62BA21;
color: white;
}
/* Other browsers see this */
.green ::selection {
background-color: #62BA21;
color: white;
}
事实上,在这种情况下,这是唯一可以做的,
In fact, in this case it's the only thing you can do, i.e. you will have to put up with this slight bit of bloat.
这篇关于Firefox :: - moz选择选择器bug(?)有没有解决方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!