简体   繁体   English

如何修复带有圆角的HTML表格上的间隙?

[英]How to fix gap on HTML table with rounded corners?

I have no access to change core HTML, only CSS, but the tables I am working with have a weird gap in the corners that I am trying to fix. 我无权更改核心HTML,只有CSS,但我正在使用的表在尝试修复的角落有一个怪异的缺口。

 .tabular-container { border: 2px solid #0093c9; border-radius: 8px; overflow: hidden; box-sizing: border-box; } .heading-row { background: #0093c9; font-weight: bold; } table { font-family: Arial; width: 100%; border-collapse: collapse; background: white; overflow-x: hidden; } th, td { padding: 10px; text-align: left; } 
 <div class="tabular-container"> <table class=""> <thead class=""> <tr class="heading-row"> <th colspan="2">Rounded corners table</th> </tr> </thead> <tbody> <tr class="tabular__row"> <td>kk</td> <td>kk</td> </tr> <tr class="tabular__row"> <td colspan="2">This is a sample table only</td> </tr> </tbody> </table> </div> 

Does turning the whole table and div background into the color and the tbody back to white do the trick? 将整个表格和div背景变成彩色,然后将tbody变回白色是否可以解决问题?

.tabular-container {
  background: #0093c9;
}

table {
  font-family: Arial;
  width: 100%;
  border-collapse: collapse;
  background: white;
  overflow-x: hidden;
  background: #0093c9;
}

tbody{
  background: white;
}

 .tabular-container { border: 2px solid #0093c9; border-radius: 8px; overflow: hidden; box-sizing: border-box; background: #0093c9; } .heading-row th{ font-weight: bold; } table { font-family: Arial; width: 100%; border-collapse: collapse; background: white; overflow-x: hidden; background: #0093c9; } th, td { padding: 10px; text-align: left; } tbody{ background: white; } 
 <div class="tabular-container"> <table class=""> <thead class=""> <tr class="heading-row"> <th colspan="2">Rounded corners table</th> </tr> </thead> <tbody> <tr class="tabular__row"> <td>kk</td> <td>kk</td> </tr> <tr class="tabular__row"> <td colspan="2">This is a sample table only</td> </tr> </tbody> </table> </div> 

Simple, set: border-radius:0; 简单设置: border-radius:0; on your table. 在你的桌子上。

The browser is trying to set the radius of the table's corners to match, but is getting a rounding error. 浏览器试图将表格的拐角半径设置为匹配,但出现了舍入错误。 By using radius:0 you are forcing the browser to 'clip' the corner instead. 通过使用radius:0,您将强制浏览器“剪切”角落。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM