Maintain the aspect ratio of a div with CSS

Just create a wrapper <div> with a percentage value for padding-bottom, like this:  Run code snippetExpand snippet It will result in a <div> with height equal to 75% of the width of its container (a 4:3 aspect ratio). This relies on the fact that for padding : The percentage is calculated with respect to the width of the generated box’s containing block … Read more