I am trying to keep aspect ratio 1:1 but following code isn't working:
.container {
background-color: red;
width: 10%;
padding-top: 100%; /* for 1:1 Aspect Ratio */
}
<div class="container"></div>
As per this article:
Even when that is a little unintuitive, like for vertical padding. This isn't a hack, but it is weird: padding-top and padding-bottom is based on an element's width. So if you had an element that is 500px wide, and padding-top of 100%, the padding-top would be 500px.
But in above code if I keep width : 10%, and padding-top: 100%, I can't get aspect ration 1:1. Why?