CSS :empty 选择器的作用
使用 CSS :empty 选择器,可以设置样式给任何没有子元素的 <p> 元素。您可以尝试运行以下代码以实现 :empty 选择器:
示例
<!DOCTYPE html>
<html>
<head>
<style>
p.demo {
width: 300px;
height: 20px;
background: gray;
}
p:empty {
width: 150px;
height: 20px;
background: orange;
}
</style>
</head>
<body>
<p class = "demo">This is demo text. Below is empty text.</p>
<p></p>
</body>
</html>
广告
数据结构
网络应用
关系型数据库
操作系统
Java
iOS
HTML
CSS
安卓
Python
C 语言程序设计
C++
C#
MongoDB
MySQL
Javascript
PHP