As % padding/margin are calculated according to the width of the contrainer, you can't use the "padding technique" to maitain aspect ratio according to the height.
For a CSS solution, you will have to use vh
units :
vh : 1/100th of the height of the viewport.
Source
For browser support see canIuse
Example for a 1:1 aspect ratio :
DEMO
CSS
div{
width: 50vh;
height: 50vh;
}