html - 如何在不加倍边框或使用边框折叠的情况下圆桌边框?
问题描述
我一直在尝试使用我为圆桌角找到的 Stack Ooverflow 答案:
/*
table {
border-collapse: collapse;
}*/
table, tr, td, th{
border: 1px solid;
text-align: center;
/*padding: 10px;*/
}
table{
border-spacing: 0;
width: 100%;
display: table;
}
table tr:last-child td:first-child, tr:last-child, table {
border-bottom-left-radius: 25px;
}
table tr:last-child td:last-child, tr:last-child, table {
border-bottom-right-radius: 25px;
}
table tr:first-child th:first-child, tr:first-child, table {
border-top-left-radius: 25px;
}
table tr:first-child th:last-child, tr:first-child, table {
border-top-right-radius: 25px;
}
<table>
<tr>
<th>Num</th><th>Lett</th><th>Lat</th>
</tr>
<tr>
<td>1</td><td>A</td><td>I</td>
</tr>
<tr>
<td>2</td><td>B</td><td>II</td>
</tr>
<tr>
<td>3</td><td>C</td><td>III</td>
</tr>
</table>
这工作正常。但如果我取消注释border-collapse
,舍入就会消失。如果我取消注释padding: 10px
,它将使边框加倍:
我需要border-collapse
避免粗体的内部边界。我需要padding
表格单元格中的文本与其边界有距离。如何在具有圆形外边框的同时实现它?
JSFiddle:https ://jsfiddle.net/eszuhvxj/1/
解决方案
您可以删除 td 上的顶部和右侧边框:
table {
border-collapse: separate;
border:none;
border-spacing: 0;
width: 30em;
--radius-border: 15px;
}
table td, table th {
border: 1px solid;
text-align: center;
padding: 10px;
}
table td {
border-top: none;
}
table tr:last-child td:first-child{
border-bottom-left-radius: var(--radius-border);
}
table tr:last-child td:last-child {
border-bottom-right-radius: var(--radius-border);
}
table tr:first-child th:first-child {
border-top-left-radius: var(--radius-border);
}
table tr:first-child th:last-child {
border-top-right-radius: var(--radius-border);
}
table tr th:not(:last-child),
table tr td:not(:last-child) {
border-right: none;
}
<table>
<tr>
<th>Num</th><th>Lett</th><th>Lat</th>
</tr>
<tr>
<td>1</td><td>A</td><td>I</td>
</tr>
<tr>
<td>2</td><td>B</td><td>II</td>
</tr>
<tr>
<td>3</td><td>C</td><td>III</td>
</tr>
</table>
推荐阅读
- javascript - 我的内容是大还是为什么我可以向下滚动?
- python - ValueError:使用拥抱脸时,在昏暗 1(得到 5)处的预期长度为 19 的序列
- reactjs - 找不到模块:无法解析“swiper/css”
- popup - 创建一个弹出窗口以获取具体付款5
- flutter - 如何为列表视图中的最后一张卡片添加底部边距?
- flutter - 如何使用共享首选项存储 3d 字符串数组
- python - 编写代码以从未排序的链表中删除重复项
- angular - 无法在primeng自动完成中模糊输入
- python - PyGAD GA - 为什么解决方案和健身阵列大小不匹配?
- terminal - zsh:权限被拒绝,但我拥有我需要的所有权限