I have an HTML table where one of the columns have thumbnail images.
table {
border-collapse:collapse;
}
td,th {
border:1px solid;
padding:0;
}
td:nth-child(2) {
/*display:flex;
justify-content:center;*/
text-align:center;
}
img {
max-height:2em;
/*display:block;*/
}
<table>
<tr><th>col1</th><th>col2</th><th>col3</th></tr>
<tr><td>a</td><td><img src='https://upload.wikimedia.org/wikipedia/commons/3/30/Dolphintursiops.jpg' /></td><td>c</td>
<tr><td>d</td><td><img src='https://upload.wikimedia.org/wikipedia/commons/thumb/b/b3/Dolphind.jpg/320px-Dolphind.jpg' /></td><td>f</td>
<tr><td>g</td><td><img src='https://upload.wikimedia.org/wikipedia/commons/thumb/3/37/Killerwhales_jumping.jpg/320px-Killerwhales_jumping.jpg' /></td><td>i</td>
</table>
If I add display:block
to the images, the space below each image disappears, but I can't center them anymore.
I tried centering with display:flex;justify-content:center
, but strangely this creates a thicker border on each cell.
How can I center the images without creating additional space or a thicker border?