:is() 和 :where()
标题中的 <b> 标签进行颜色调整:
| h1 > b, h2 > b, h3 > b, h4 > b, h5 > b, h6 > b { | |
| color: hotpink; | |
| } |
现在,我们可以使用 :is() 缩减代码并提高其可读性:
| :is(h1,h2,h3,h4,h5,h6) > b { | |
| color: hotpink; | |
| } |
使用 :where()
| :where(h1,h2,h3,h4,h5,h6) > b { | |
| color: hotpink; | |
| } | |
:is() 和 :where() 组合使用
| :is(.dark-theme, .dim-theme) :where(button,a) { | |
| color: rebeccapurple; | |
| } | |
| :is(h1,h2):where(.hero,.subtitle) { | |
| text-transform: uppercase; | |
| } | |
| .hero:is(h1,h2,:is(.header,.boldest)) { | |
| font-weight: 900; | |
| } |