Css 选择嵌套元素
我将一个类分配给一个类为“level”的div中的第一个div。很好 如果父div具有id=“selected”,则需要交换样式。选择它有困难Css 选择嵌套元素,css,Css,我将一个类分配给一个类为“level”的div中的第一个div。很好 如果父div具有id=“selected”,则需要交换样式。选择它有困难 .level:first-child div:nth-child(1) { background-position: 0px -368px; } .level:first-child div:nth-child(1) #selected { background-position: 0px -429px; background-c
.level:first-child div:nth-child(1) {
background-position: 0px -368px;
}
.level:first-child div:nth-child(1) #selected {
background-position: 0px -429px;
background-color:red
}
将
id
放在前面
#selected.level:first-child div:nth-child(1) {
background-position: 0px -429px;
background-color:red
}
将
id
放在前面
#selected.level:first-child div:nth-child(1) {
background-position: 0px -429px;
background-color:red
}
试试这个:
.level:first-child div:nth-child(1) {
background-position: 0px -368px;
}
.level:first-child#selected div:nth-child(1) {
background-position: 0px -429px;
background-color:red
}
示例:尝试以下方法:
.level:first-child div:nth-child(1) {
background-position: 0px -368px;
}
.level:first-child#selected div:nth-child(1) {
background-position: 0px -429px;
background-color:red
}
例如: