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).
html code
css code
img { position: relative; top: 50%; transform: translateY(-50%); }