html - 具有自定义边框的 CSS 表格

标签 html css

我受困于简单的表格设计,因为我来自后端,我需要这样的表格


enter image description here


我现在拥有的

table {
	border-collapse: collapse; 
    width: 100%;
}
tr { 
	border: none; 
}
.first{
    width: 40%;
    font-family: Quasimoda;
    font-size: 0.75em;
    color: #1D1D1E;
}
.middle{
    width: 60%;
    font-family: Quasimoda;
    font-size: 0.75em;
    color: #1D1D1E;
}
.last{
    width: 40%;
    font-family: Quasimoda;
    font-size: 0.75em;
    color: #1D1D1E;
}
td {
  border-bottom: 1px solid #ddd;
  border-top: 1px solid #ddd;
  padding: 10px;
}
<table>
  
  <tr>
    <td class="University">January</td>
    <td class="middle ">the progress bar will be placed here </td>
    <td class="last">870</td>
  </tr>
  <tr>
    <td class="first">January</td>
    <td class="middle ">the progress bar will be placed here </td>
    <td class="last">560</td>
  </tr>
</table>

请帮忙。我尝试了多个 html 表格属性,但都没有用。

最佳答案

设置thead tr元素的底边框,以及.first元素的右边框:

table {
  border-collapse: collapse;
  width: 100%;
}

th {
  text-align: left;
  border-bottom: 1px solid #ddd;
}

td {
  padding: 10px;
  font-family: Quasimoda;
  font-size: 0.75em;
  color: #1D1D1E;
}

.first {
  border-right: 1px solid #ddd;
}

.middle {
  width: 100%;
}
<table>
  <thead>
    <tr>
      <th colspan="3">Unique values:</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td class="first">January</td>
      <td class="middle ">the progress bar will be placed here </td>
      <td class="last">870</td>
    </tr>
    <tr>
      <td class="first">January</td>
      <td class="middle ">the progress bar will be placed here </td>
      <td class="last">560</td>
    </tr>
  </tbody>
</table>

关于html - 具有自定义边框的 CSS 表格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58338975/

相关文章:

html - 如何在页脚中并排放置两个图标(图像)?

javascript - 样式 - 垂直对齐 td 标签内标签内的图像和文本

html - 创建轮播时使用的角色 ="listbox"是什么?

html - 如何使用 JSON 定义创建 html 表单?

html - 在 HTML/CSS 中显示类似图表的 png 图像

php - 使用CSS创建水平树

javascript - 使用 JavaScript 两次(或多次)插入 HTML 元素

css - 用于输入元素的 webkit htm5 css 重置

javascript - 通过 C# 在 EmailTemplate.html 中打印数组

html - Bootstrap 菜单总是折叠的问题