html - 带有自定义边框的 CSS 表格
问题描述
我坚持使用简单的表格设计,因为我来自后端我需要这样的表格
我现在拥有的
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>
推荐阅读
- python - Python 重定向运算符文件名
- javascript - Change background-color with javascript, with same button no jquery or other
- java - 尝试在 IntelliJ 中运行 maven javafx-archetype-simple 时出错
- python - 调用时 Numba CUDA ctypes.ArgumentError
- c# - 如何使用 Xamarin.iOS 将广告内容分配给 stacklayout
- c# - 从对象 Checksphere 中淡化 UI 文本并进行交互
- javascript - 使用 JS 检测移动设备中的关闭选项卡/浏览器
- kotlin - Ktor自定义json对象反序列化
- css - 对线性梯度的段应用不同的角度
- laravel - 如何从laravel中的函数将值传递给两个视图?