我正在尝试在CSS中设置一个边框半径为12px的表格。在表内的tr或td上没有边界,只是整个地块周围的一个边界。我希望表中的第一行在顶部的2个角上有一个边界半径,而不是在底部的2个角上(所以它就像是表的标题),这是我设法做到的。但是,这会在表和第一行之间创建一个白色边框-我希望它们彼此对齐,而不是白色边框,因为标题行有彩色背景。
我试过使用边框折叠来做这件事,但是这抵消了整个表格上的边框半径,使标题行在顶部的两个角上四舍五入,但在一个正方形的表格内。
这很难解释,所以可以在here中找到一个例子。您可以看到表和具有蓝色背景的行之间的白色边框。
有谁知道如何在不崩溃的情况下摆脱边界吗?提前感谢
发布于 2012-10-25 02:43:37
试试这个:
<table class="admin" style = "border-spacing:0px;">
显然,您可以将这种内联样式放入它自己的类中,但我想明确地向您展示,表中的边界间距才是您想要的。
如果你不想让文本紧贴在表格的边框上,你应该/可以在表格内的内容中添加一些填充。
发布于 2013-05-02 21:24:15
以下是我的css修复:
table {
border:1px solid black;
border-radius: 5px; //Any radius you want. It will work perfectly!
border-spacing: 0;
}
table td:first-child, table td:not(:first-child):not(:last-child){
border-right:1px solid black;
}
table tr:first-child td, table tr:not(:last-child) td {
border-bottom:1px solid black;
}
table thead tr:first-child td:first-child {
-webkit-border-top-left-radius: 2px;
-moz-border-radius-topleft: 2px;
border-top-left-radius: 2px;
}
table thead tr:first-child td:last-child {
-webkit-border-top-right-radius:2px;
-moz-border-radius-topright: 2px;
border-top-right-radius: 2px;
}
table tbody tr:last-child td:first-child {
-webkit-border-bottom-left-radius: 2px;
-moz-border-radius-bottomleft: 2px;
border-bottom-left-radius: 2px;
}
table tbody tr:last-child td:last-child {
-webkit-border-bottom-right-radius: 2px;
-moz-border-radius-bottomright: 2px;
border-bottom-right-radius: 2px;
}https://stackoverflow.com/questions/13055620
复制相似问题