此时高度与宽度的变化 - Fiddle
* {
padding: 0;
margin: 0;
box-sizing: border-box;
}
.aspect-ratio-1 {
padding-bottom: 100%; /* (value height = value width) = 1 * 100% = 100% */
position: relative;
background: #999;
}
.aspect-ratio-1-inner {
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
}
<div class="aspect-ratio-1">
<div class="aspect-ratio-1-inner"></div>
</div>
如何使垂直调整大小自动更改并等于块的高度(如果可能,在css上)?
谢谢,我将很乐意为您提供帮助!