css - 是否可以为多个前缀选择器编写一条 CSS 规则?

标签 css css-selectors pseudo-element

请参阅 this question 的答案.我写 CSS 规则:

::-webkit-input-placeholder,:-moz-placeholder,::-moz-placeholder,:-ms-input-placeholder {
    color:    #999;
}

因此 firefox 无法识别其元素(-moz-placeholder 和 -moz-placeholder)。为什么?可以将所有这些伪元素写在一个 CSS 规则中吗?

最佳答案

简短的回答:没有。此行为符合 W3C 规范 ( see 4.1 )。也就是说,如果任何选择器列表包含一个或多个无效的选择器,则整个选择器列表将被视为无效,因此您不能对特定于浏览器的选择器进行分组。

Warning: the equivalence is true in this example because all the selectors are valid selectors. If just one of these selectors were invalid, the entire selector list would be invalid. This would invalidate the rule for all three heading elements, whereas in the former case only one of the three individual heading rules would be invalidated.

关于css - 是否可以为多个前缀选择器编写一条 CSS 规则?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17672698/

相关文章:

html - Chrome 开发工具如何生成 CSS 选择器?

css - 在::after或::before伪元素内容中添加换行符

android - Phonegap App, Html/Css 安卓老浏览器调试

此选择器的子项上的 jquery 动画

css - 第 n 个子选择器的 SASS 编译错误

html - 我可以使用 :before or :after pseudo-element on an input field? 吗

css - 使用 CSS 将内容放在 anchor 标记之外

javascript - 是否可以访问网页未解析的 CSS 文本?

jquery - Owl Carousel 2 - 中心和覆盖

Android:在 setSelecton 上突出显示列表中的项目