I have this situation in which I want to render a div
as a square, where the height determines the width. So far the only solution which comes very close is to use an 1px by 1px image:
<div class="square">
<img src="data:image/gif;base64,R0lGODlhA...RAA7">
</div>
.square {
display:inline-flex;
height:100%;
background:darkorange;
}
img {
display:block;
height:100%;
width:auto;
}
But whatever I try, when I change the height, the square is stretch vertically (not a square any more). You have to hit reload to make it a square again. This seems to happen only in Chrome. Although in the original post it is suggested to use display: inline-flex
for .square
it doesn't seem to work. Maybe I did missed something. Any suggestions?