CSS3 já era coisa fina. Agora, na sua versão 4, ou melhor dizendo, em seu nível 4, como será dividido a partir de agora, tem muita coisa bacana. Uma delas é o seletor :matches
.
Com ele, podemos substituir por exemplo, uma marcação assim:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
div .highlight, | |
footer .highlight { | |
color: blue; | |
} |
Para algo assim:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
:matches(div, footer) .highlight { | |
color: blue; | |
} |
Ou seja, atacamos
toda classe highlight
que seja filha de uma div
ou footer
.
Podemos ainda fazer da maneira inversa, como no exemplo abaixo: onde selecionamos todos elementos p
que tenham a classe success
ou que seja ":first-child
.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
p:matches(:first-child, .success) { | |
color: green; | |
} |