新的 CSS 伪类函数 :is() 和 :where()

Posted on   书中枫叶  阅读(87)  评论(0编辑  收藏  举报

: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;
}
相关博文:
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?
历史上的今天:
2021-08-15 vue中使用echarts的两种方法

随笔 - 24, 文章 - 0, 评论 - 13, 阅读 - 59464

Copyright © 2025 书中枫叶
Powered by .NET 9.0 on Kubernetes

点击右上角即可分享
微信分享提示