CSS:可以选择某个孩子加上紧随其后的兄弟姐妹吗?

发布于 2024-10-02 13:29:59 字数 199 浏览 0 评论 0原文

我目前正在使用 Javascript 执行此操作,但是,我想知道是否可以使用 CSS 选择无序列表的某个子项,然后选择其直接兄弟项。

有 4 个列表项的示例:

ul.tab li:hover + (the next sibling that follows the current hovered one) {

}

I'm currently doing this using Javascript, however, I was wondering if it's possible to select a certain child of an unordered-list and then its immediate sibling, using CSS.

Example with 4 list-items:

ul.tab li:hover + (the next sibling that follows the current hovered one) {

}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

凉城凉梦凉人心 2024-10-09 13:29:59

您需要 相邻同级选择器,有趣的是您基本上已经掌握了语法。

请注意::hover 是 Safari 中特定的 x 浏览器问题。

You want the adjacent sibling selector for which you amusingly basically have the syntax already.

Be advised: :hover is specifically a x-browser problem in Safari though.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文