So the answer to your question(s) is/ are:
I have a div that grows dynamically depending on the content
Use 'float' (shrink-to-fit) or 'display: inline-block' for the (containing) DIV element.
while maintaining a 1:1 aspect ratio
To achieve this you can use 'padding-top' or 'padding-bottom' with a percentage value representing the desired aspect ratio (in case of 1:1 it will be 100%) on a 'dummy' element, which will be a child of the containing DIV. The second child then will be absolute positioned (remember to relative position the containing DIV).
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
And if the height is actually heigher than the height set by the width, you additionally need
overflow: auto;
max-height: 100%;
for your element.
That's it - DEMO
and a
that can differ in size (the "dynamic content")
– johnny Sep 11 '13 at 12:17