html代碼:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0,user-scalable=no">
<title>html5無邊框響應式table表格佈局</title>
<link rel="stylesheet" type="text/css" href="table.css"/>
</head>
<body>
<table class="VirusTable">
<thead>
<tr>
<th>
<div>地區</div>
</th>
<th>
<div>確診</div>
</th>
<th>
<div>治癒</div>
</th>
<th>
<div>死亡</div>
</th>
</tr>
</thead>
<tbody>
<tr>
<td>湖北</td>
<td>13522</td>
<td>396</td>
<td>414</td>
</tr>
<tr>
<td>廣西</td>
<td>189</td>
<td>10</td>
<td>0</td>
</tr>
<tr>
<td>廣東</td>
<td>762</td>
<td>25</td>
<td>2</td>
</tr>
<tr>
<td>湖南</td>
<td>230</td>
<td>16</td>
<td>1</td>
</tr>
</tbody>
</table>
</body>
</html>
css代碼:
.VirusTable {
table-layout: fixed;
width: 100%;
margin-top: .5rem;
padding-bottom: .5rem;
text-align: center;
border-spacing: 2px 6px;
font-size: .938rem;
color: #4d5054;
border-collapse: collapse;
}
.VirusTable tr {
height: 1.875rem;
line-height: 1.875rem;
}
.VirusTable td,
.VirusTable th {
text-align: center;
width: 30%;
}
.VirusTable thead {
font-size: .938rem
}
.VirusTable thead tr {
color: #555;
text-align: center;
line-height: 1
font-weight: 700;
}
.VirusTable tbody tr {
height: 2rem;
line-height: 2rem;
border-bottom: 1px solid #f5f5f5;
}
.VirusTable tbody tr:last-child {
border-bottom: none;
}
.VirusTable tbody tr td {
color: #4d5054;
}
.VirusTable tbody tr td:first-child{
color: #00BEC7;
font-weight: 700;
}