Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
是否可以在 CSS(包括 3 个)中做这样的事情?
ul li:visible:nth-child(odd) {...}
纯粹使用 CSS 是不可能的。您可以链接伪类,例如li:nth-child(2n):hover但是:visiblejQuery,而不是 CSS。
li:nth-child(2n):hover
:visible
CSS 没有类似的功能,因为 CSS 当前无法确定元素是否可见
我同意安迪但它不会选择第一个元素所以添加+1并且代码将li:nth-child(2n+1):hover.参考安迪的答案
+1
li:nth-child(2n+1):hover.