gpt4 book ai didi

html - 在 ul 中使用第 nth-last-child css

转载 作者:太空宇宙 更新时间:2023-11-03 23:13:49 25 4
gpt4 key购买 nike

你能帮我设计一下这个 ul 中最后一个链接的样式吗?

#DeltaTopNavigation ul.root.ms-core-listMenu-root.static a {
vertical-align: middle !important;
padding: 0 35px;
border-right: 1px #dadada solid;
}
<div id="DeltaTopNavigation" class="ms-core-navigation" role="navigation">
<div class=" noindex ms-core-listMenu-horizontalBox">
<ul class="root ms-core-listMenu-root static">
<li class="static">
<a class="static menu-item ms-core-listMenu-item ms-displayInline ms-navedit-linkNode" tabindex="0" href="/" accesskey="1"></a>
<ul class="static">
<li class="static selected">
<a class="static selected menu-item ms-core-listMenu-item ms-displayInline ms-core-listMenu-selected ms-navedit-linkNode" tabindex="0" href="/AboutPGTU"></a>
</li>
<li class="static">
<a class="static menu-item ms-core-listMenu-item ms-displayInline ms-navedit-linkNode" tabindex="0" href="/Docs"></a>
</li>
<li class="static">
<a class="static menu-item ms-core-listMenu-item ms-displayInline ms-navedit-linkNode" tabindex="0" href="/Services"></a>
</li>
<li class="static">
<a class="static menu-item ms-core-listMenu-item ms-displayInline ms-navedit-linkNode" tabindex="0" href="/Ratings"></a>
</li>
</ul>
</li>
</ul>
</div>

我尝试使用

#DeltaTopNavigation ul.root.ms-core-listMenu-root.static a:nth-last-child(1) {
border: 0 ;
}

但它为所有链接设置了 border:0。我怎样才能只对最后一个执行此操作?

最佳答案

您需要在 li 上使用 last-child 而不是在 a 上使用 nth-last-child()

#DeltaTopNavigation ul.root.ms-core-listMenu-root.static a {
vertical-align: middle !important;
padding: 0 35px;
border-right: 1px #dadada solid;
}
#DeltaTopNavigation ul.root.ms-core-listMenu-root.static li ul.static li:last-child a {
border: 0;
}
<div id="DeltaTopNavigation" class="ms-core-navigation" role="navigation">
<div class=" noindex ms-core-listMenu-horizontalBox">
<ul class="root ms-core-listMenu-root static">
<li class="static">
<a class="static menu-item ms-core-listMenu-item ms-displayInline ms-navedit-linkNode" tabindex="0" href="/" accesskey="1"></a>
<ul class="static">
<li class="static selected">
<a class="static selected menu-item ms-core-listMenu-item ms-displayInline ms-core-listMenu-selected ms-navedit-linkNode" tabindex="0" href="/AboutPGTU"></a>
</li>
<li class="static">
<a class="static menu-item ms-core-listMenu-item ms-displayInline ms-navedit-linkNode" tabindex="0" href="/Docs"></a>
</li>
<li class="static">
<a class="static menu-item ms-core-listMenu-item ms-displayInline ms-navedit-linkNode" tabindex="0" href="/Services"></a>
</li>
<li class="static">
<a class="static menu-item ms-core-listMenu-item ms-displayInline ms-navedit-linkNode" tabindex="0" href="/Ratings"></a>
</li>
</ul>
</li>
</ul>
</div>

关于html - 在 ul 中使用第 nth-last-child css,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31535516/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com