简单,你可以使用:empty选择器 <p></p><!-- NOT empty: note the blank space --><p></p><!-- YES empty: nothing inbetween --> p::before{font-family:"FontAwesome";content:"\f240";}p:empty::before{content:"\f244";}p{color:silver;}p:empty{color:red;} empty 是什么意思? 当我第...
[CSS3] :empty Selector When the element has empty content, you might want to display some text to idicate the compoent is loading... <!DOCTYPE html><html><head><style>p:empty{width:100px;height:20px;background:#ff0000;}p:empty:after{content:"Loading..., please wait"}</style></...
基本的选择器规则(Selector) 类型(Type)选择器 类(Class)选择器 ID 选择器 参数(Attribute)选择器 通配符 组合选择器(Combinator) 子选择器和后代选择器 兄弟选择器和相邻兄弟选择器 选择器列表 伪类(Pseudo-Classes) 链接和按钮相关 表单输入相关 DOM 子节点相关 DOM 相关的其他伪类 其他 伪元素(Pseudo-elements...
唯一类型元素选择器(Only of Type Selector) task23 html23 答案:apple:only-of-type 第二十四关 最后类型元素选择器(Last of Type Selector) task24 html24 答案:orange:last-of-type,apple:last-of-type 第二十五关 空选择器(Empty Selector) task25 html25 答案:bento:empty 第二十六关 反向选择器(Negat...
2、 :empty 选择器 **:empty选择器 选择每个没有任何子级的元素(包括文本节点)。 没有任何子级 指的是 有空标签都不行!!!** <title>:empty 选择器</title> <style> /* :empty选择器 选择每个**没有任何子级**的元素(包括文本节点)。 没有任何子级 指的是 有空标签都不行!!! */ ...
ID 选择器(ID Selector):通过元素的唯一标识符(ID)选择 HTML 元素。 ID 选择器以#开头,后面跟着 ID 名称。 如下代码,#runoob选择器将选择具有 ID 为"runoob"的元素。 #runoob {width:200px;} 属性选择器(Attribute Selector):通过元素的属性选择 HTML 元素。属性选择器可以根据属性名和属性值进行选择。
:empty选择器、:target选择器。 这些基本上都很常用,今天着重说下:否定伪类:not() 否定伪类特别有用,在css中, :not选择器 用于匹配非指定元素/选择器的每个元素,语法格式: :not(selector) 比如:假设我想选择所有 div,除了 id 为 的那个 container。下面代码: ...
:empty选择器选择每个没有任何子级的元素(包括文本节点)。 2、实例 指定空的p元素的背景色: p:empty{ background:#ff0000; } 7.2.6 :not() 选择器 1、定义 :not(selector) 选择器匹配每个元素是不是指定的元素/选择器。 2、实例 为每个并非<p>元素的元素设置背景颜色: ...
(1):nth-last-child(1)| | E:only-of-type | 匹配父元素下使用同种标签的唯一一个子元素,等同于:first-of-type:last-of-type或 :nth-of-type(1):nth-last-of-type(1)| | E:empty | 匹配一个不包含任何子元素的元素,文本节点也被看作子元素| | E:not(selector) | 匹配不符合当前选择器的...