目标父级li不是css的子级
我想用css选择器来定位父li,而不是子li目标父级li不是css的子级,css,css-selectors,Css,Css Selectors,我想用css选择器来定位父li,而不是子li <ul> <li>{Target the li of this ul only}</li> <li>{Target the li of this ul only}</li> <li> <ul> <li>{it would be different sty
<ul>
<li>{Target the li of this ul only}</li>
<li>{Target the li of this ul only}</li>
<li>
<ul>
<li>{it would be different styling}</li>
<li>{it would be different styling}</li>
<li>{it would be different styling}</li>
</ul>
</li>
</ul>
- {仅针对此ul的li}
- {仅针对此ul的li}
-
- {这将是不同的样式}
- {这将是不同的样式}
- {这将是不同的样式}
为两个ul提供不同的课程,并将风格应用到他们的孩子身上
.a>li{
颜色:绿色
}
.b>李{
颜色:红色
}
- {仅针对此ul的li}
- {仅针对此ul的li}
-
- {这将是不同的样式}
- {这将是不同的样式}
- {这将是不同的样式}
您尝试了哪个选择器失败?我不想向元素添加任何类,也不想重复代码来覆盖父css样式。只想为父li添加css样式。如果我们以ul>li为目标,它也会反映出孩子们想要实现的目标,而不需要添加任何类或属性。希望为不反映在子元素上的父元素添加CSS。