I need to maintain the width of an element as a percentage of its height. So as the height changes, the width is updated.
The oppo
The CSS trick you wrote, works pretty well to keep ratio width
/ height
on an element.
It is based on the padding
property that, when its value is in percent, is proportional to parent width, even for padding-top
and padding-bottom
.
There is no CSS property that could set an horizontal sizing proportionally to the parent height. So I think there is no clean CSS solution.