Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/80.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html :not(:empty):类型的第一个不';不行?_Html_Css_Css Selectors - Fatal编程技术网

Html :not(:empty):类型的第一个不';不行?

Html :not(:empty):类型的第一个不';不行?,html,css,css-selectors,Html,Css,Css Selectors,我想在第一个非空元素前面显示一个文本,该元素的类为error。我使用了。错误:not(:empty):第一个类型::before,但它不起作用。我错过了什么 .error:not(:empty):first-of-type::before { content: attr(seq); display: block; background-color:red; } 不起作用: <div> <p class="error" seq="Error #1

我想在第一个非空元素前面显示一个文本,该元素的类为
error
。我使用了
。错误:not(:empty):第一个类型::before
,但它不起作用。我错过了什么

.error:not(:empty):first-of-type::before {
    content: attr(seq);
    display: block;
    background-color:red;
}
不起作用:

<div>
    <p class="error" seq="Error #1" ></p>
    <p class="error" seq="Error #2">2</p>
    <p class="error" seq="Error #3">3</p>
    <p class="error" seq="Error #4"></p>
    <div><b> Some text here  </b>
    <p></p>
</div>

2

3

这里有一些文字

工作正常:

 <div>
    <p class="error" seq="Error #1" >1</p>
    <p class="error" seq="Error #2">2</p>
    <p class="error" seq="Error #3">3</p>
    <p class="error" seq="Error #4"></p>
    <div><b> Some text here  </b>
    <p></p>
</div>

1

2

3

这里有一些文字


PS:我也试过了
:firstchild
。也不起作用。

:类型的第一个
表示“类型的第一个元素(也称为标记名)”而不是“与选择器其余部分匹配的第一个元素”


CSS选择器无法描述所需的条件。您需要采取其他方法(例如,在生成HTML时添加额外的类名)。

:类型的第一个
表示“类型的第一个元素(也称为标记名)”而不是“与选择器其余部分匹配的第一个元素”


CSS选择器无法描述所需的条件。您需要采取其他方法(例如,在生成HTML时添加一个额外的类名)。

请定义您期望在这里发生的事情,而这段代码不做。请定义您期望在这里发生的事情,而这段代码不做。真的吗?真的吗?真的吗(