My web page does not use pixels to define the width and height and instead uses percentage. I have a table with three rows and three columns. The first table cell of each row contains a Div and in each Div of each table row there is an image. The images display just fine except for a small problem and that is each image has a different height. That means the height of each table row and Div are only as high as the image the Div contains.
I suspect this happens because I dimensioned the table and its cells using percent. I noticed that the width of the td element works but the height of the td element doesn’t seem to work. I would like to place an image of any size into any of the rows and have CSS force all of the images to be displayed with the same height and width without using pixel width or height.
If the images have varying aspect ratios then some cropping must occur. This can be done using the object-fit property, though that does not have IE support.
There are workarounds and polyfill that can emulate the effect in unsupporting browsers, or you could just accept that IE users will have to slum-it with a less than perfect layout.
Assuming you have a need for a table the i would use object-fit with a fallback method for older browsers like this:
However your percentages seem much too small to be of any practical use so I guess they were just for example.
Also you don’t say what should happen when the text to the side of the image runs to more lines than the 33% height. If its only one word like your example that that should be ok but generally you should test with extravagant data to show up any problems straight away.
The above layout could be achieved without using the html table element if the data is not tabular.
That’s the way I would have approached it apart from one small point.
The aspect ratio of the image is not maintained and the images are just squashed into place. You can fix it for modern browsers (excluding ie and edge) using object-fit.
e.g.
.row img {
object-fit: cover;
}
Of course I may be wrong in my assumptions that aspect ratio needs to be maintained and in which case don’t add the object-fit