是否可以为几个前缀选择器写一个CSS规则? [英] Is it possible to write one CSS rule for several prefixed selectors?

查看:129
本文介绍了是否可以为几个前缀选择器写一个CSS规则?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请参阅此问题的答案。我写CSS规则:

  ::  -  webkit-input-placeholder,: -  moz-placeholder ,::  -  moz-placeholder,: -  ms-input-placeholder {
color:#999;因此,firefox无法识别其元素(-moz-placeholder和-moz-placeholder),因此firefox不能识别其元素(-moz-placeholder和-moz-占位符)。为什么?可以在一个CSS规则中写所有这个伪元素?

解决方案

此行为符合W3C规范(请参阅4.1 )。也就是说,如果任何选择器列表包含一个或多个无效的选择器,则整个选择器列表被视为无效,因此您无法分组特定浏览器的选择器。


警告:在此示例中的等效性为true,因为所有
选择器都是有效的选择器。如果只有其中一个选择器
无效,整个选择器列表将无效。这将使
使所有三个标题元素的规则无效,而在
前一种情况下,三个单独的标题规则中只有一个是
无效。


< blockquote>

See answer for this question. I write CSS rule:

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

So firefox can not recognize its elements (-moz-placeholder and -moz-placeholder). Why? It is possible to write all this pseudo element in one CSS rule?

解决方案

Short answer: no. This behaviour is accordance with the W3C spec (see 4.1). That is if any selector list contains one or more selectors that are invalid, the entire selector list is considered invalid, hence you cannot group browser-specific selectors.

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规则?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆