css - 仅针对父级 li 而不是具有 css 的子级
问题描述
我想针对父 li,而不是仅使用 css 选择器的子 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 styling}</li>
<li>{it would be different styling}</li>
<li>{it would be different styling}</li>
</ul>
</li>
</ul>
解决方案
给两个 ul 不同的课程,并将风格应用到他们的孩子 li
.a>li {
color: green
}
.b>li {
color: red
}
<ul class='a'>
<li>{Target the li of this ul only}</li>
<li>{Target the li of this ul only}</li>
<li>
<ul class='b'>
<li>{it would be different styling}</li>
<li>{it would be different styling}</li>
<li>{it would be different styling}</li>
</ul>
</li>
</ul>
推荐阅读
- javascript - 模块构建失败(来自 ./node_modules/sass-loader/dist/cjs.js):使用 webpack 配置响应应用程序
- php - 如何检查两个基于 GPS 的 A 到 B 距离是否在任何点重叠/交叉?
- openid - OAuth2.0/OIDC 规范中的 response_type 和 grant_type
- java - Vaadin 14 - 未创建服务工作者和清单
- reporting-services - SSRS 参数的表达式预期错误
- javascript - 在 Express 响应中使用 Javascript 函数发送数据
- javascript - React-Slick SlickGoTo 实现不起作用
- oracle - Oracle 中的保存点
- websocket - Erlang Ranch Websocket 客户端无法检测到断开的 Internet 连接
- selenium - 通过悬停或任何方式单击按钮来单击隐藏元素