「CSS」border-collapse テーブルの枠線を重ねるサンプル
環境
Google Chrome 102.0.5005.115
構文
border-collapse : 値
collapseはテーブルの枠線(ボーダー)を重ねて表示します。
border-collapse は CSS のプロパティで、表 (<table>) の中のセルが境界を共有するか分離するかを設定します。
使用例
<!DOCTYPE html>
<html>
<head>
<style>
table {
/* 枠線(ボーダー)を重ねて表示 */
border-collapse: collapse;
width: 100px;
background: skyblue;
}
td {
border: 1px solid #000;
}
</style>
</head>
<body>
<table>
<tr>
<td>1001</td>
<td>tt</td>
</tr>
<tr>
<td>2002</td>
<td>oo</td>
</tr>
</table>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<style>
table {
/* 枠線(ボーダー)を重ねて表示 */
border-collapse: collapse;
width: 100px;
background: skyblue;
}
td {
border: 1px solid #000;
}
</style>
</head>
<body>
<table>
<tr>
<td>1001</td>
<td>tt</td>
</tr>
<tr>
<td>2002</td>
<td>oo</td>
</tr>
</table>
</body>
</html>
<!DOCTYPE html> <html> <head> <style> table { /* 枠線(ボーダー)を重ねて表示 */ border-collapse: collapse; width: 100px; background: skyblue; } td { border: 1px solid #000; } </style> </head> <body> <table> <tr> <td>1001</td> <td>tt</td> </tr> <tr> <td>2002</td> <td>oo</td> </tr> </table> </body> </html>
結果
border-collapseにcollapseを指定しています。テーブルの枠線が重なります。