接下来,我将给大家讲述下CSS4选择器的语法:
:matches()选择器
描述::matches()是个伪类选择器。但是在CSS4选择器中,它可以将选择器列表作为参数。样式应用于传递的参数没有表示的元素。
语法:
1 2 3 4 5 6 7 8 | E:matches(s1, s2, ...) { /* Where s1 and s2 are two different selectors. */ } /* The following are the browser supported versions of the :matches() pseudo-class. */ E:-webkit-any(s1, s2, ...) { /* Chrome, Opera */ } E:-moz-any(s1, s2, ...) { /* Firefox */ } |
例子:
1 2 3 4 5 | /* In this example, all p elements which are the first child or have a class special will be red. */ p:matches(:first-child, .special) { color: red; } |
浏览器支持:
Chrome | Friefox | Safari | Opera | IE | Edge | |
Desktop | -webkit | -moz | yes | -webkit | no | no |
Mobile | -webkit | -moz | yes | -webkit | no | no |