简体   繁体   English

HTML CSS 圆角表

[英]HTML CSS Table with rounded corners

I have little problem with my table.我的桌子没什么问题。 It is stylized by classes.它按类风格化。 One for TABLE that makes rounded corners and changes background to grey.一个用于制作圆角并将背景更改为灰色的 TABLE。 The other is to make rest of the table white and I assign it to TBODY.另一种是把表的rest变成白色,我赋值给TBODY。 After second class is asigned, bottom-left and bottom-right corners are no longer rounded.第二个class赋值后,左下角和右下角不再圆角。

<table align=center class="grey">
  <thead>
    <tr height=50>
      <th>header</th>
      <th>header</th>
    </tr>
  </thead>
  <tbody class="white">
    <tr height=50>
      <td>row two</td>
      <td>row two</td>
    </tr>

    <tr height=50 class="white">
      <td>row three</td>
      <td>row three</td>
    </tr>
  </tbody>
</table>

body {
  background: #000;
}

table.grey {
    background: #F6F2F5;
    border: 3px solid #FFF;
    text-align: center;
    width: 80%;
    padding: 15px;
    border-collapse: collapse;
    border-left: 0;
    border-right: 0;
    border-radius: 10px;
    border-spacing: 0px;
}
.white {
  background: #FFF;
  color: #000;
  padding: 50px;
  border-bottom-left-radius: 10px;
  border-bottom-right-radius: 10px;
}

Giving class to TR of each row gives same result as to TBODY.将 class 赋值给每一行的 TR 给出与 TBODY 相同的结果。 I'm dumb.我很笨https://jsfiddle.net/2tm4z90b/8/ https://jsfiddle.net/2tm4z90b/8/

Like this.像这样。

 table { border-radius: 5px; border: 1px solid black; } table thead { background: gray; }
 <table align=center class="grey"> <thead> <tr height=50> <th>header</th> <th>header</th> </tr> </thead> <tbody class="white"> <tr height=50> <td>row two</td> <td>row two</td> </tr> <tr height=50 class="white"> <td>row three</td> <td>row three</td> </tr> </tbody> </table>

tbody cannot really be styled, it is part of the structure of a table and is not supposed to be seen, nor styled unless you reset its display but that will break your table-layout. tbody不能真正设置样式,它是表格结构的一部分,不应该被看到,也不应该设置样式,除非您重置其显示,但这会破坏您的表格布局。

Option are选项是

  • to set the radius only on the table and use overflow.仅在桌子上设置半径并使用溢出。
  • fake the border via a box-shadow if needed, so it follows the rounded shape如果需要,通过框阴影伪造边框,使其遵循圆形

Possible example:可能的例子:

 body { background: #000; } table.grey{ margin-top:3em; background: gray; box-shadow:0 0 0 3px red;/* instead border */ text-align: center; width: 80%; padding: 15px; border-collapse: collapse; border-left: 0; border-right: 0; border-radius: 10px; border-spacing: 0px; overflow:hidden; /* hide overflowing cells */ }.white tr { background: #bee; color: #000; padding: 50px; }
 <table align=center class="grey"> <thead> <tr height=50> <th>header</th> <th>header</th> </tr> </thead> <tbody class="white"> <tr height=50> <td>row two</td> <td>row two</td> </tr> <tr height=50> <td>row three</td> <td>row three</td> </tr> </tbody> </table>

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

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