Since vertical paddings set in percent are calculated out of width of an element we can make a div always be of a certain aspect ratio.
If we set padding-top:50%; height:0
, the height of the div will always be half of its width.
And to make text appear inside such a container you need to make it position:relative
and put another div inside it and position it absolutely 10px away from all four sides (the padding you set first).
See my fork of your code.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…