<table border="1">
<tr>
<td><img src="photo1.jpg" alt="說明文字"></td>
<td><img src="photo2.jpg" alt="說明文字"></td>
<td><img src="photo3.jpg" alt="說明文字"></td>
</tr>
</table>
table.img-grid {
width: 100%;
border-collapse: collapse;
table-layout: fixed; /* 固定佈局,避免內容撐開 */
}
table.img-grid td {
padding: 8px;
text-align: center;
vertical-align: middle;
}
table.img-grid img {
max-width: 100%;
height: auto;
display: block;
margin: 0 auto;
}
表格語意為「資料表格」,純圖片展示建議改用:
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }
.gallery img { width: 100%; height: 200px; object-fit: cover; border-radius: 8px; }