css - 从嵌套的动态导航列表中选择最后一个 a:link
问题描述
我正在尝试:after
从一堆嵌套的无序列表中删除 a:link 的伪元素的内容。我似乎无法选择它。
如何为这个动态创建的导航列表选择最后一个 a:link?谢谢。
HTML
<nav class="site-nav children-links">
<span class="parent-link">
<a href="http://localhost/learnwebcode/index.php/sample-grandparent/">
Sample grandparent
</a>
</span>
<ul>
<li class="page_item page-item-2 page_item_has_children current_page_item"><a href="http://localhost/learnwebcode/index.php/sample-grandparent/sample-page/" aria-current="page">Sample Parent Page</a>
<ul class="children">
<li class="page_item page-item-16">
<a href="http://localhost/learnwebcode/index.php/sample-grandparent/sample-page/sample-child-one/">Sample child one</a>
</li>
<li class="page_item page-item-18">
<a href="http://localhost/learnwebcode/index.php/sample-grandparent/sample-page/sample-child-two/">Sample child two</a>
</li>
</ul>
</li>
</ul>
</nav>
CSS
.children-links a:after {
content: "➤";
}
.children-links ul:last-child li a:last-child:after {
content: "";
}
解决方案
根据您给定的结构,您必须选择.chidren
ul
.
锚链接始终是最后一个子节点,li
因此不需要任何额外的选择器。
.children-links ul.children li:last-child a:after {
content: "";
}
推荐阅读
- python-3.x - 如何使用请求知道 API 的响应数据类型
- c# - 如何使集成测试中的请求有效?
- android - 如何设置底片的最大高度可以以其他方式 WRAP_CONTENT?
- angular - Angular 中的变更检测是重新渲染 DOM 的唯一机制吗?
- azure - 使用 Terraform 通过 Microsoft.Storage.BlobCreated 事件创建 Azure 事件订阅过滤
- sql - 按日期透视预订状态
- machine-learning - 我在训练 BERT 模型时出错
- java - 如何在android中模糊imageview的背景图像
- html - 选择不带标签的自由子元素的 XPath
- typo3 - TYPO3/TypoScript - 在 DataProcessor 中使用 FIELD() 自定义排序