css伪类函数

74 阅读1分钟
  • :where
  • :is

二者作用相同,但是:is 比 :where高, 可以设置多元素的共同css,简略很多啊

:is(p, h5, div, a) {
    color: aqua;
}

:where(p, h5, div, a) {
    color: rgb(233, 186, 32);
}

使用:is 的效果
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;
}