在table中設置border-radius發現不起作用,網上查找了一番,原因是border-collapse:collapse和border-radius不兼容。
css:
border-collapse: separate;
border-spacing: 0;
設計圖效果

代碼實現效果:
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
<style>
#table_wrap > table {
font-size: 16px;
text-align: center;
margin: 0 auto;
border-collapse: separate;
border-spacing: 0;
border: 2px #000;
}
table thead tr,table tbody tr {
height: 50px;
line-height: 50px;
/*background-color: pink;*/
}
table tr th:first-child,table tr td:first-child {/*設置table左邊邊框*/
border-left: 2px solid #eaeaea;
}
table tr th:last-child,table tr td:last-child {/*設置table右邊邊框*/
border-right: 2px solid #eaeaea;
}
table tr td:first-child,
table tr td:nth-child(2),
table tr td:nth-child(3),
table tr td:last-child{/*設置table表格每列底部邊框*/
border-bottom: 2px solid #eaeaea;
}
/*table tr:last-child td:first-child,
table tr:last-child td:nth-child(2),
table tr:last-child td:nth-child(3),
table tr:last-child td:last-child{/!*設置table表格最后一列底部邊框*!/
border-bottom: 2px solid #000;
}*/
table tr th {
background: #eaeaea;
}
table tr:first-child th:first-child {
border-top-left-radius: 12px;
}
table tr:first-child th:last-child {
border-top-right-radius: 12px;
}
table tr:last-child td:first-child {
border-bottom-left-radius: 12px;
}
table tr:last-child td:last-child {
border-bottom-right-radius: 12px;
}
</style>
</head>
<body>
<div id="table_wrap">
<table class="table" width="800" cellspacing="0" cellpadding="0">
<thead class="table_head">
<tr>
<th>頭部1</th>
<th>頭部2</th>
<th>頭部3</th>
<th>頭部4</th>
</tr>
</thead>
<tbody>
<tr>
<td>1內容1</td>
<td>1內容2</td>
<td>1內容3</td>
<td>1內容4</td>
</tr>
<tr>
<td>2內容1</td>
<td>2內容2</td>
<td>2內容3</td>
<td>2內容4</td>
</tr>
<tr>
<td>3內容1</td>
<td>3內容2</td>
<td>3內容3</td>
<td>3內容4</td>
</tr>
</tbody>
</table>
</div>
</body>
</html>
