I have seen similar questions and this began by using the answer provided:
.wraptocenter {
float: left;
position: relative;
display: table-cell;
text-align: center;
vertical-align: middle;
width: 200px;
height: 200px;
background-color: yellow;
border: solid black 1px;
}
.wraptocenter * {
vertical-align: middle;
}
<div class="wraptocenter"><img src="http://www.brunildo.org/thumb/tmiri2_o.jpg" /></div>
<div class="wraptocenter"><img src="https://img.xcitefun.net/users/2015/01/382650,xcitefun-philippines-tour-1.jpg" /></div>
<div class="wraptocenter"><img src="http://www.brunildo.org/thumb/tmiri2_o.jpg" /></div>
<div class="wraptocenter"><img src="http://www.brunildo.org/thumb/tmiri2_o.jpg" /></div>
<div class="wraptocenter"><img src="http://www.brunildo.org/thumb/tmiri2_o.jpg" /></div>
<div class="wraptocenter"><img src="http://www.brunildo.org/thumb/tmiri2_o.jpg" /></div>
<div class="wraptocenter"><img src="http://www.brunildo.org/thumb/tmiri2_o.jpg" /></div>
It doesn't work as I want. I want my wraptocenter
div containers to float one after he other and go down to the next row. If I remove float
then they center but all of then squish on one row. When I add float
the image is no longer centered vertically.
In the final HTMl I will want to use various images of different dimensions, all of which should be central.
I don't want to use any special elements (like flex grids). Just basic html / css.