I am working with Products that have images of maximum size 100px. This means either the width is 100px and the height is less than 100px, or the height is 100px and the width is less than 100px. One side always measures 100px.
My goal is to display the product image on the right side, and the name and price on the bottom left of that image. The layout structure I require can vary in different cases:
I attempted this:
<table style="width: 100%;">
<tbody>
<tr>
<td style="height: 100px; ">
<a href="@Url.Action("Details", "Product", new { id = Model.Id })" >
<img src="@Url.Content("~/Images/" + Model.Image)" style="float:right;" alt="" />
<b style="margin-top: 15%; float: right;">
<label>@Model.Price</label>
<br />
<label>@Model.Name</label>
</b>
</a>
</td>
</tr>
</tbody>
</table>
However, this only works for an image height of 100px. The margin-top: 15%;
property is static. It needs to adjust when the image height is 50px, 60px, etc. How can I achieve this? It's not necessary to use a table. Any element suggestions are welcome.
EDIT:
I added another <td>
side by side and placed the price and name in the first <td>
, and the image in the second <td>
.
Now I need to set the <td>
width based on the inner elements' sizes. If the image width in the <td>
is 90px, I want to set the <td>
width to 90px. Is this possible?