html - 最后一个子元素的 CSS 边框半径

标签 html css css-tables

我有这个代码:

tr:first-child th:last-child    {
    -webkit-border-top-left-radius: 15px;
    -moz-border-radius-topleft: 15px;
    border-top-left-radius: 15px;
}
tr:first-child th:first-child   {
    -webkit-border-top-right-radius: 15px;
    -moz-border-radius-topright: 15px;
    border-top-right-radius: 15px;
}
tr:last-child th:last-child {
    -webkit-border-bottom-left-radius: 15px;
    -moz-border-radius-bottomleft: 15px;
    border-bottom-left-radius: 15px;
}
tr:last-child th:first-child    {
    -webkit-border-bottom-right-radius: 15px;
    -moz-border-radius-bottomright: 15px;
    border-bottom-right-radius: 15px;
}

我对 <td> 做了同样的事情标签也是如此。

它应该使 table 变圆。

现在我遇到了一个问题。

我的网站中有一张表隐藏了 <td>在最后一行,用户需要点击<th>行显示 <td> .

CSS 假设我有 <td><tr>的最后一个 child 中所以它被四舍五入。但问题是它是隐藏的。

<th>位于 <tr>用户实际看到的最后一个 child ,但由于最后一个 <td> 而没有被四舍五入这是隐藏的,看起来很糟糕。

有什么建议吗?

最佳答案

使用nth-last-child 。它从末尾选择 rx+n 的每个元素。 (:nth-last-child(r+n) 或只是 :nth-last-child(n) (假设 r 为 0))

tr:nth-last-child(2) th:last-child {}

关于html - 最后一个子元素的 CSS 边框半径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21722946/

相关文章:

html - 将粘性页脚放置在粘性标题下的固定左列旁边

javascript - 全日历 : trouble rendering events with ajax when pressing 'prev' or 'next'

css - CSS "display: table-column"应该如何工作?

html - 多个列表并排放置并带有样式标题标题

html - 打开表单列表时自动选择第一个表单

javascript - 未捕获( promise )DOMException : Failed to execute 'texImage2D' on 'WebGL2RenderingContext' : Tainted canvases may not be loaded

html - 方向为 : column but multi-column stack by-side 的 Flexbox

Jquery Mobile 幻灯片列表

html - 将基于表格的 HTML 布局重构为 CSS 的工具?

html - CSS 特定表