Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/33.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 CSS选择同一类名中的子类_Html_Css - Fatal编程技术网

Html CSS选择同一类名中的子类

Html CSS选择同一类名中的子类,html,css,Html,Css,我有一个用户将输入的HTML。我的工作是选择“mychild”类名,并为每个mychild设置不同的颜色 问题:我使用了first of type或nth-of-type()。因此,first of type,nth-of-type()或first chil不是解决方案 .parent.mychild:类型的第一个{ 文字装饰:下划线; 背景:黄色; } .parent.mychild:第n个类型(2){ 文字装饰:下划线; 背景:红色; } .parent.mychild:第n个类型(3)

我有一个用户将输入的HTML。我的工作是选择“mychild”类名,并为每个mychild设置不同的颜色

问题:我使用了
first of type
nth-of-type()。因此,
first of type
nth-of-type()
first chil
不是解决方案

.parent.mychild:类型的第一个{
文字装饰:下划线;
背景:黄色;
}
.parent.mychild:第n个类型(2){
文字装饰:下划线;
背景:红色;
}
.parent.mychild:第n个类型(3){
文字装饰:下划线;
背景:绿色;
}

小孩
小孩
小孩
小孩
小孩
小孩
小孩
小孩
小孩

Hi Andrei Gheorghiu,你能删除“重复”吗?因为我的问题完全不同。Thanks@abcidd您的问题不清楚您的需求是什么,因此这不值得重新打开(因为它会因为不清楚而重新关闭)。例如,您的标记总是这样,还是最终会有第四个或第五个
myChild
?介于两者之间的
其他
儿童如何;总是有两个吗?无论如何,我已经找到了一个真正合适的复制品,并调整了横幅以显示该复制品。嗨,Andrei Gheorghiu,你能删除“复制品”吗?因为我的问题完全不同。Thanks@abcidd您的问题不清楚您的需求是什么,因此这不值得重新打开(因为它会因为不清楚而重新关闭)。例如,您的标记总是这样,还是最终会有第四个或第五个
myChild
?介于两者之间的
其他
儿童如何;总是有两个吗?无论如何,我已经找到了一个真正合适的复制品,并调整了横幅以显示该复制品。