有没有办法显示仅当中没有其他可见行时只使用CSS?

发布于 2024-12-09 11:36:29 字数 164 浏览 0 评论 0原文

我知道使用 jQuery 显示和隐藏的能力;不幸的是,传递所有必要的参数是难以管理的,所以我正在寻找一个 CSS 技巧,它将使该行不可见,除非所有其他行都被隐藏。

我尝试使用 style="margin-bottom: -20px",但这没有效果。有这样的东西可以工作吗?

I'm aware of the ability to show and hide with jQuery; unfortunately, it would be unmanageable to pass around all the necessary parameters, so what I'm looking for is a CSS trick that will make the row invisible unless all the other rows are hidden.

I tried using a style="margin-bottom: -20px", but this had no effect. Is there something like this that would work?

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

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

发布评论

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

评论(1

匿名的好友 2024-12-16 11:36:29

您可以显示一个元素,当且仅当它是其父元素的唯一子元素时,如下所示:

tbody > tr.Special {
    display: none;
}

tbody > tr.Special:only-child {
    display: table-row;
}

不适用于 IE<9

You can show an element iff it's the only child of its parent like this:

tbody > tr.Special {
    display: none;
}

tbody > tr.Special:only-child {
    display: table-row;
}

This will not work on IE<9

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