直接给div设置: padding-bottom: 100%;
<div style="width: 100px;height: 100px;border: 1px solid black;margin: 100px auto;">
<div style="padding-bottom: 100%;background: red;"></div>
</div>
<div style="width: 200px;height: 200px;border: 1px solid black;margin: 100px auto;">
<div style="padding-bottom: 100%;background: red;"></div>
</div>