zoukankan      html  css  js  c++  java
  • [CSS] The :empty Pseudo Selector Gotchas

    The :empty pseudo selector selects empty elements. We can use this to display useful messages instead of the empty content or hide the content completely. However, the :empty pseudo selector comes with a couple of potentially confusing behaviors when it comes to which elements it considers empty.

    <!DOCTYPE html>
    <html lang="">
      <head>
        <meta charset="utf-8" />
        <style type="text/css">
          p {
            background: rgb(255, 211, 233);
            margin-top: 10px;
            margin-bottom: 0px;
            padding: 10px;
          }
          // Be carefual that img is also considered as an empty element
          *:empty {
            display: none;
          }
        </style>
      </head>
    
      <body>
        <p></p>
        <p>Some content</p>
        <p></p>
        <img
          width="200px"
          height="200px"
          src="https://source.unsplash.com/user/erondu/daily"
        />
      </body>
    </html>
  • 相关阅读:
    论语言思维的差异
    lua经典问题
    跳槽的故事
    未来一年计划
    腾讯面试题 找重复的数
    nodejs学习
    node记录
    mysql 常用总结
    ubuntu 服务器搭建汇总
    ubuntu下安装golang
  • 原文地址:https://www.cnblogs.com/Answer1215/p/11527278.html
Copyright © 2011-2022 走看看