我的问题是,当使用伪代码 :last-child
我希望包含 E
的 li
会受到样式的影响,但是受影响的是 .subNav
中的最后一个 li
。
我已经尝试过这些(如下),但没有任何效果。
nav ul:first-child li:last-child {border: none;padding-right: 0;}
nav ul:not(.subNav) li:last-child {border: none;padding-right: 0;}
如何让主ul
的最后一个li
受到影响?
最佳答案
在最后一个 li 之后有一个 div。因此,它不是最后一个 child 。您可以使用 :last-of-type
以最后一个 li 为目标:
nav ul li:last-of-type {border: none;padding-right: 0;}
关于css - ul li :last-child affects the last li in the second ul,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25762098/