I am trying to put a background image in a table cell (td) but since the image is larger than the cell I can see only a part of the background image.
The html looks like this:
<tr>
<td class="active"></td>
<td class="passive"></td>
</tr>
in the classes I am using this css:
background-image: url('../Images/prospectAct.png');
width: 100%;
height: auto;
The <td> are 8% width and I can make the image fit the cell.
Any example that I can test?
You can use background-size:contain;
td {
width:100px;
height:100px;
}
td.active {
background-image:url('http://placehold.it/200x200');
background-size:contain;
}
<table>
<tr>
<td class="active"></td>
<td class="passive"></td>
</tr>
</table>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With