I have implemented a PHP script that automatically resizes images proportionally to fit within a given height and width. For example, if the original picture is 200x100px and the target box is 180x180px, the resized image will be 180x90px.
Although this script works well, I am facing an issue with centering the image inside a div using CSS tricks which usually require knowing the dimensions in advance.
The only solution I have found so far is to create an outer div with display: table;
and another div containing the image with
display: table-cell; vertical-align: middle; text-align: center;
.
Are there any other alternatives to achieve this alignment?