Is there a way to set the height of an element as a percentage of the parent’s width?
I know you can use the percentage unit to set the child’s height relative to the parent’s height (e.g. height: 40%), but I’m looking for a way to set the child’s height relative to the parent’s width (or more generally, a child’s dimension relative to the parent’s other dimension).
No, I get how to apply the padding or padding-top property. What I wasn’t getting is how it answers the question. I tried it, so now I understand what you mean, but it unfortunately has the side effect of changing height based on the content of the child element, which is not what I’m looking for. Thanks, though!
Hey, my friend. Umm, not really, no. I’ve had that problem before. Could you share a codepen or something I could fork? Sometimes it can be accomplished with CSS variables.