Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/38.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 - Fatal编程技术网

Html 第一个孩子的概念对我不起作用?

Html 第一个孩子的概念对我不起作用?,html,css,Html,Css,我正在从日历中选择“日期范围”。我只想在该日历中为“开始日期”和“结束日期”添加其他样式。我有日历“选定行”的类名。但我正在尝试第一个孩子和最后一个孩子的概念。我不知道为什么它不起作用。如何为表td(日历行)中的第一个孩子和最后一个孩子添加css? 添加第一个子项之前 添加第一个孩子后第一个孩子和最后一个孩子不会像这样工作 <style> .here:first-child{color:red;} .there:last-child{color:blue;} </style&

我正在从日历中选择“日期范围”。我只想在该日历中为“开始日期”和“结束日期”添加其他样式。我有日历“选定行”的类名。但我正在尝试第一个孩子和最后一个孩子的概念。我不知道为什么它不起作用。如何为表td(日历行)中的第一个孩子和最后一个孩子添加css?

添加第一个子项之前


添加第一个孩子后

第一个孩子
最后一个孩子
不会像这样工作

<style>
.here:first-child{color:red;}
.there:last-child{color:blue;}
</style>
<ul>
  <li>one
  <li class="here">two
  <li class="there">three
</ul>

.here:first child{color:red;}
.那里:最后一个孩子{颜色:蓝色;}
  • 一个 两个 三个
您可能期望第二个元素为红色,但它不会。这是因为这里类为
的项不是第一个子项(它是第二个子项)。

因为类为
的元素也是最后一个子元素,所以它将是蓝色的。

共享代码而不是图像