想要使用CSS刪除表格中空單元格的邊框,可以使用empty-cells屬性。empty-cells屬性用於指定是否在表格的單元格無內容時顯示邊框。只有當表格邊框獨立(例如當border-collapse屬性等於separate時)此屬性才起作用。
原文地址:CSS如何刪除表格中空單元格的邊框?
empty-cells屬性設置或檢索當表格的單元格無內容時,是否顯示該單元格的邊框。
語法:
empty-cells: show|hide;
屬性值:
● show:用於顯示空單元格上的邊框;邊框和背景正常渲染。
● hide:邊框和背景被隱藏。
示例:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>empty-cell屬性</title>
<style>
table.show {
empty-cells: show;
}
td {
text-align:center;
}
table.hide{
empty-cells: hide;
}
</style>
</head>
<body>
<center>
<h2>empty-cells: show;</h2>
<table class="show" border="1">
<tr>
<td width="100px">HTML</td>
<td width="100px">CSS</td>
</tr>
<tr>
<td>javascript</td>
<td></td>
</tr>
</table>
<h2>empty-cells: hide;</h2>
<table class="hide" border="1">
<tr>
<td width="100px">HTML</td>
<td width="100px">CSS</td>
</tr>
<tr>
<td>javascript</td>
<td></td>
</tr>
</table>
</center>
</body>
</html>
效果圖:
推薦閱讀: