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

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

Posted on 

: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;
  }

本文来自博客园,作者:书中枫叶,转载请注明原文链接:https://www.cnblogs.com/zy-mg/p/16588245.html

posted on   漫思  阅读(12)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· 微软正式发布.NET 10 Preview 1:开启下一代开发框架新篇章
· C# 集成 DeepSeek 模型实现 AI 私有化(本地部署与 API 调用教程)
· DeepSeek R1 简明指南:架构、训练、本地部署及硬件要求
· NetPad:一个.NET开源、跨平台的C#编辑器
· 面试官:你是如何进行SQL调优的?
历史上的今天:
2017-04-11 WPF开发中的多线程的问题

导航

< 2025年2月 >
26 27 28 29 30 31 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 1
2 3 4 5 6 7 8
点击右上角即可分享
微信分享提示