css - 边框半径在 table 上不起作用

标签 css

表格中的边框半径仅在背景上工作,边框保持笔直。

Image with my prolem

这是我的CSS

.table_mem, .th_mem, .tr_mem, .td_mem{
    border: 1px solid #000000;
    border-radius: 20px;
    border-collapse: collapse;
    text-align: center;
   padding: 7px;
}
.th_mem{ background-color: #9e9e9e;}
.tr_mem{ background-color: #e5e5e5; transition: .5s;}
.tr_mem:hover{ background-color: #bfbfbf; }

谁能告诉我一个解决方案?

最佳答案

边界是直的因为折叠,简单设置border-collapseseparate:

body { padding-top: 1em; }

.table_mem,
.table_mem thead th,
.table_mem tbody tr,
.table_mem tbody td {
  border: 1px solid #000000 !important;
  border-radius: 20px;
  border-collapse: separate;
  text-align: center;
  padding: 7px;
}

.table_mem thead th {
  background-color: #9e9e9e;
}

.table_mem tbody tr {
  background-color: #e5e5e5;
  transition: .5s;
}

.table_mem tbody tr:hover {
  background-color: #bfbfbf;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container">
  <table class="table table_mem">
    <thead>
      <tr>
        <th>Firstname</th>
        <th>Lastname</th>
        <th>Email</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td>John</td>
        <td>Doe</td>
        <td>john@example.com</td>
      </tr>
      <tr>
        <td>Mary</td>
        <td>Moe</td>
        <td>mary@example.com</td>
      </tr>
      <tr>
        <td>July</td>
        <td>Dooley</td>
        <td>july@example.com</td>
      </tr>
    </tbody>
  </table>
</div>

jsfiddle:https://jsfiddle.net/azizn/kkv9guhx/

关于css - 边框半径在 table 上不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39778619/

相关文章:

html - 试图将搜索栏向右移动但保持在边界内

html - 垂直对齐按钮排成一行

css - bootstrap-ui 中的底部对齐列

html - float : left problems while using DIVs?

html - 透明背景滚动条显示在内容顶部

html - 根据页面宽度按比例缩放容器中的图像

Javascript 为多个元素设置 CSS 类(一个元素集,其余元素未设置)

animation - Ext js 4 动画风格

css - 如何正确放置单选按钮?

css - 第 n 个 child 对类没有反应