gpt4 book ai didi

html - 如何防止表格单元格边框从 "bleeding"相互插入

转载 作者:行者123 更新时间:2023-12-04 08:36:16 24 4
gpt4 key购买 nike

html {
background-color: #fff;
font-family: Arial;
}
body {
display: flex;
justify-content: center;
}
td {
background-color: #fafafa;
}
th:first-child, td:first-child {
border-left-style: none;
}
th:last-child, td:last-child {
border-right-style: none;
}
th:first-child {
border-top-left-radius: 1rem;
}
th:last-child {
border-top-right-radius: 1rem;
}
tr:last-child td {
border-bottom-style: none;
background-color: #efefef;
}
tr:last-child td:first-child {
border-bottom-left-radius: 1rem;
}
tr:last-child td:last-child {
border-bottom-right-radius: 1rem;
}
<html>
<head>
<style>
::selection {
background-color: #0dd; color: #099;
}
table, th, td {
padding: 1rem;
border-style: solid;
border-color: #eee;
border-collapse: collapse;
}
table {
margin-top: 1rem;
border-style: none;
}
th {
border-top-style: none;
border-color: #111;
background-color: #222;
color: #fff;
border-bottom-color: #fff;
}
</style>
</head>
<body>
<table>
<tr> <th>One</th><th>Two</th><th>Three</th> </tr>
<tr> <td>four</td> <td>five</td><td>six</td> </tr>
<tr> <td>seven</td> <td>eight</td><td>nine</td> </tr>
</table>
</body>
</html>

enter image description here <th> 中的垂直表格边框元素向下延伸到 <td> 上的水平顶部边框下面的元素。我们如何防止这种情况并使边界看起来正常而不会相互“流血”?
我已将其分解为一个非常简单的示例,其中包含简单的代码以隔离问题。我仍然没有找到解决方案。
编辑 :目前这似乎只出现在 Chrome 中。不确定这是否是具有快速破解/修复功能的已知错误。任何帮助,将不胜感激。

最佳答案

简单而不是使用白色bottom border使用黑色见下文

html {
background-color: #fff;
font-family: Arial;
}
body {
display: flex;
justify-content: center;
}
td {
background-color: #fafafa;
}
th:first-child, td:first-child {
border-left-style: none;
}
th:last-child, td:last-child {
border-right-style: none;
}
th:first-child {
border-top-left-radius: 1rem;
}
th:last-child {
border-top-right-radius: 1rem;
}
tr:last-child td {
border-bottom-style: none;
background-color: #efefef;
}
tr:last-child td:first-child {
border-bottom-left-radius: 1rem;
}
tr:last-child td:last-child {
border-bottom-right-radius: 1rem;
}
<html>
<head>
<style>
::selection {
background-color: #0dd; color: #099;
}
table, th, td {
padding: 1rem;
border-style: solid;
border-color: #eee;
border-collapse: collapse;
}
table {
margin-top: 1rem;
border-style: none;
overflow: hidden;
}
th {
border-top-style: none;
border-color: #111;
background-color: #222;
color: #fff;
border-bottom-color: #222;
position: relative;
}
th::before {
content: '';
height: 2px;
width: 105%;/*its not proper solution but a hack*/
position: absolute;
bottom: -3px;
left:0;
right:0;
background: red;
}
</style>
</head>
<body>
<table>
<tr> <th>One</th><th>Two</th><th>Three</th> </tr>
<tr> <td>four</td> <td>five</td> <td>six</td> </tr>
<tr> <td>seven</td> <td>eight</td> <td>nine</td> </tr>
</table>
</body>
</html>

注意:用于 table header 之间的边界和 table body请编辑 th::before

关于html - 如何防止表格单元格边框从 "bleeding"相互插入,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64781134/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com