I have the following code which sets up a container which has a height that changes with the width when the browser is re-sized (to maintain a square aspect ratio).
With flexbox this is easy:
FIDDLE
Just add the following to the image container:
.img-container { position: absolute; top: 0; bottom: 0; left: 0; right: 0; display: flex; /* add */ justify-content: center; /* add to align horizontal */ align-items: center; /* add to align vertical */ }