我有一张桌子的样式并不像我想象的那样.

The left side border is too thick, and the background colour on the right doesn't quite fit perfectly within the border radius: image showing the incorrect styling

我不知道为什么会这样,有什么 idea 吗?我已经在MWE中包含了我的代码.

table {
    font-family: Avenir, Helvetica, Arial, sans-serif;
    width: 100%;
    background-color: #ffffff;
    border-collapse: collapse;
    border-width: 2px;
    border-color: #dedede;
    border-style: solid;
    color: #000000;
    border-radius: 10px;
    border-collapse: separate !important;
    border-spacing: 0;
  }

  table td, table th {
    border-right: solid 1px #dedede;
    border-left: solid 1px #dedede;
    padding: 10px;
  }

  table thead {
    font-size: 1.6em;
  }

  table th:last-child {
    border-right: 0px;
    border-top-right-radius: 10px;
    background-color: #edf2f4;
  }

  table td:last-child {
    border-right: 0px;
    background-color: #edf2f4;
  }

  .last-td {
    border-right: 0px;
    border-bottom-right-radius: 10px;
    background-color: #edf2f4;
  }
<table>
  <thead>
    <tr>
      <th> alpha </th>
      <th> beta </th>
    </tr>
  </thead>
  <tbody>

    <tr>
      <td> lorem </td>
      <td> lorem </td>
    </tr>
  </tbody>
</table>

推荐答案

在我的解决方案中,一切看起来都是正确的.

table {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  width: 100%;
  background-color: #ffffff;
  border-collapse: separate;
  border-spacing: 0;
}
table tr th,
table tr td {
  border-right: 2px solid #dedede;
  border-bottom: 2px solid #dedede;
  padding: 10px;
}

table tr th:first-child,
table tr td:first-child {
  border-left: 2px solid #dedede;
}
table tr th:first-child,
table tr td:first-child {
  border-left: 2px solid #dedede;
}
table tr th {
  background: #eee;
  text-align: left;
  border-top: solid 2px #dedede;
}

table td:last-child {
  background-color: #edf2f4;
}

/* top-left border-radius */
table tr:first-child th:first-child {
  border-top-left-radius: 10px;
}

/* top-right border-radius */
table tr:first-child th:last-child {
  border-top-right-radius: 10px;
}

/* bottom-left border-radius */
table tr:last-child td:first-child {
  border-bottom-left-radius: 10px;
}

/* bottom-right border-radius */
table tr:last-child td:last-child {
  border-bottom-right-radius: 10px;
}
<div>
    <table>
        <tr>
            <th>item1</th>
            <th>item2</th>
        </tr>
        <tr>
            <td>item1</td>
            <td>item2</td>
        </tr>
        <tr>
            <td>item1</td>
            <td>item2</td>
        </tr>
        <tr>
            <td>item1</td>
            <td>item2</td>
        </tr>
    </table>
</div>

Html相关问答推荐

卡片上方的文本

窗口对象中是否有对<;html&>根元素的引用?

在元素之间添加空格

如何在div中淡入和淡出渐变背景?

动态FormControl值在Angular 上绑定错误的问题

每个元素的CSS网格高度相等,以保持响应性

如何用等宽字体固定数字在有序列表中的位置

使用bash从html表格中提取表格

列表项文本在占据剩余空间之前在标记下换行

如何制作';在第';页中搜索;是否发现多个元素中的单词?

`table>;的消失;tbody:nth子级(1)`HTML

Tailwind CSS 忽略我的元素的填充

仅 Select 悬停的级别,而不 Select 其父级或子级

视频重新加载而不是在 Swift 中暂停 WKWebView

标题在实时网站上闪烁

使用简单的 HTML 设计公司徽标和文本

如何为Vuetify输入控件减小标签和字段之间的间距?

那边界从何而来?

为什么 text-align 应用于 span 而不是 CSS 中的 img

Header 或 P 标记中的填充不能与 em 单元一起正常工作