Is there a way in CSS/3 to maintain the shape ratio of a div while keeping it responsive?
Let's say the container is 100px wide.
For example:
width: 100%;
height: 100%-of-width;
Result: The div is 100px wide and 100px high.
Another example:
width: 80%
height: 60%-of-width;
Result: The div is 80px wide and 48px high.
Is there a solution for this in CSS?
Despite options like auto, vw, and various hacks available, there doesn't seem to be a straightforward solution yet. Is anyone aware of one? It's frustrating that in 2016 we still have to resort to padding hacks or potentially using JavaScript to solve this issue.
EDIT:
- Padding-bottom can be cumbersome as it requires absolute positioning of inner elements.
- Vw units are based on screen size, which may not be suitable for all cases.