I need a working solution to perform the three-sided task of centering images with different sizes, to a square div, when float: left is used to place images in rows.I use a div inside a div to do the trick:
.outer-element{
display:table-cell;
width:300px;height:300px;
text-align:center ;
vertical-align:middle ;
float:left;
margin-bottom:15px;
}
.inner-element{
display:inline-block;
}
BUT I have to use use float: left for the outer element to put the images in rows, and when the images are not centered vertically (they are aligned on the top border of the div), I tried some other CSS codes, but float: left always makes the images not vertically centered.
source
share