带有边框半径和粘性标题的 HTML 表格

标签 html css html-table css-position sticky

我有一个 HTML <table>border-radius和使用 position: sticky 的粘性标题看起来像这样:

https://codepen.io/muhammadrehansaeed/pen/OJpeeKP

enter image description here

但是,当使用粘性标题滚动时,表格行会在粘性标题的圆 Angular 所在的位置突出。见这张图片的左上角:

table row borders displayed in area cut out by border radius of sticky header

有没有一种方法可以在使用粘性标题向下滚动时保持圆 Angular ,或者当标题变得粘性并从其原始位置向下移动时移除粘性标题?理想情况下,我想要一个 CSS only 解决方案。

最佳答案

您可以使用伪元素隐藏部分边框:

table thead th:first-child::before, 
table thead th:last-child::after {
    width: 1px;
    height: 5px;
    background: white;
    content: "";
    display: block;
    position: absolute;
    top: 0px;
}
table thead th:first-child::before {
    left: -1px;
}
table thead th:last-child::after {
    right: -1px;
}

关于带有边框半径和粘性标题的 HTML 表格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68119133/

相关文章:

javascript - 当 CKEditor 破坏 <span> 时,如何在其中包含带有 HTML 的工具提示

css - body 标签是否有一些控制其他元素的样式规则?

c# - 删除具有空单元格的表格行c#

javascript - 如何让 Wordpress 'Preview' 链接在同一窗口中打开?

jquery - 如何使用 bootstrap 3 隐藏表格中的空单元格

javascript - 图片最大高度

html - 页面在移动设备中不垂直滚动

html - 如何使表格单元格的背景透明

javascript - 如何使用纯 Javascript 将我的输入链接到我的表?

jquery - Bootstrap 3 列移动问题