请参阅 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/