JZTXT
  • 首页
  • Ai
  • Java
  • Python
  • Android
  • Mysql
  • JavaScript
  • Html
  • CSS

[CSS 3] :has selector

发布时间 2023-07-06 03:08:44作者: Zhentiw

html:

    <div class="post">
      <h2>Post</h2>
      <a href="#"> a link</a>
    </div>
    <div class="post">
      <h2>Post</h2>
    </div>
    <div class="post">
      <a href="#"> a link</a>
    </div>

Want to target the .post has <h2>, also has <a>

.post:has(h2):has(a) {
   background: red;
 }

 

    本栏目推荐文章
  • 现代 CSS 解决方案:文字颜色自动适配背景色!
  • 跟着阿灵学前端(2)——CSS 基础
  • Eloquent 模型使用详解 Has One Through 远程一对一
  • CSS
  • CSS
  • CSS实现文字滑动亮光效果
  • devmapper: Thin Pool has 162394 free data blocks which is less than minimum required 163840 free data blocks
  • 前端学习-HTML/CSS刷题笔记01
  • 解决前后端的跨域问题:Access to XMLHttpRequest at '**' from origin '**' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
  • web前端css框架有哪些
版权声明:本网站为非赢利性站点,本网站所有内容均来源于互联网相关站点自动搜索采集信息,相关链接已经注明来源。
联系我们