Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/75.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 你能帮助解决第一个孩子和第二个选择器的问题吗?_Html_Css Selectors - Fatal编程技术网

Html 你能帮助解决第一个孩子和第二个选择器的问题吗?

Html 你能帮助解决第一个孩子和第二个选择器的问题吗?,html,css-selectors,Html,Css Selectors,我需要在每个部分的第一个子项后显示单词first: section:first-child::after { content: "first"; } 因为您没有设置元素的父元素。CSS中的所有元素都继承自body。 在您的示例中,部分被处理为: body section: first-child 如果节元素之前没有任何内容,并且它是正文的第一个子元素,那么它将具有指定的属性。 其他属性将被忽略 您应该将部分包装到一个容器中。例如: <div id="parent">

我需要在每个部分的第一个子项后显示单词
first

section:first-child::after {
     content: "first";
}

因为您没有设置元素的父元素。CSS中的所有元素都继承自
body
。 在您的示例中,
部分
被处理为:

body section: first-child
如果
元素之前没有任何内容,并且它是
正文
的第一个子元素,那么它将具有指定的属性。 其他属性将被忽略

您应该将
部分
包装到一个容器中。例如:

<div id="parent">
  <section>...</section>
  <section>...</section>
</div>

CSS会在每个部分的底部插入一个文本节点,上面写着“first”。但是我怎么能在每个部分类型的第一个子项后面插入单词“first”?
.parent section:first-child::after {
  content: "first";
}