html - 项目符号仅在第一个列出的 li 上,不嵌套
问题描述
我有这个列表,列表上有黄色项目符号。但是,如果还有嵌套的 ul,则希望将它们删除。有没有办法只做那个CSS?
ul.list-bullets--yellow {
position: relative;
list-style: none;
margin-left: 1.25rem;
padding-left: 1.75rem;
}
ul.list-bullets--yellow li:before {
content: "\25CF";
position: absolute;
left: 0;
color: #F2A900;
}
<ul class="list-bullets--yellow">
<li>Lifecycle Automation – employees, contractors, business partners, RPA/bots</li>
<li>Identity Governance controls: </li>
// this ul li are the ones that I only want the default html bullet. not the yellow
<ul>
<li>Role-based access control (RBAC) model</li>
<li>Policy model–suitability and separation of duties (SOD)</li>
</ul>
<li>Account and Password Management</li>
</ul>
解决方案
这可以通过切换ul.list-bullets--yellow li:before
到ul.list-bullets--yellow > li:before
这是一个 CSS “子选择器”,您可以在w3schools上阅读更多关于它们的信息。基本上添加的>
只有当它li:before
是的直接孩子时才说ul.list-bullets--yellow
ul.list-bullets--yellow {
position: relative;
list-style: none;
margin-left: 1.25rem;
padding-left: 1.75rem;
}
ul.list-bullets--yellow > li:before {
content: "\25CF";
position: absolute;
left: 0;
color: #F2A900;
}
<ul class="list-bullets--yellow">
<li>Lifecycle Automation – employees, contractors, business partners, RPA/bots</li>
<li>Identity Governance controls: </li>
// this ul li are the ones that I only want the default html bullet. not the yellow
<ul>
<li>Role-based access control (RBAC) model</li>
<li>Policy model–suitability and separation of duties (SOD)</li>
</ul>
<li>Account and Password Management</li>
</ul>
推荐阅读
- powershell - 我正在编写我的第一个 powershell 脚本来删除交换时的旧 TMP/LOG 文件
- powershell - Powershell比较2个csv文件
- mysql - 当我使用“加入”时,Laravel 查询非常慢。3000 万条记录
- node.js - 如何在 nodejs 中使用 getRandomValues()?
- android - 未从活动中的 Firestore 字段中获取正确的值
- html - 如何从您的网站中删除多个 nbsp
- vba - 使用 VBA 在 Solidworks 中创建两 (2) 个边缘法兰
- javascript - 使用 Vue 变量作为索引访问对象数组时,Vue.js“无法读取未定义的属性‘未定义’”
- sql - SQL 函数非常慢
- reactjs - 将输入传递给 React 兄弟