0

I have a parent div with a variable size, and a child div inside with its width set to 100% to fill up the parent div horizontally.

I'd like the height of the child div to be equal to its width at any time, to have an aspect ratio of 1:1 for the child div. The parent div has a different aspect ratio.

How could I achieve that ?

vbuzze
  • 930
  • 1
  • 11
  • 25
  • How would you change the height and width of the child div? through javascript or ? – Anandhu Aug 12 '18 at 22:15
  • I know I could do it with JS but I'd like to know if there were any CSS way to achieve this. I'm working with React so I'd like to avoid manipulating the DOM directly. – vbuzze Aug 12 '18 at 22:21

0 Answers0