CSS保持宽高比(aspect-ratio)VS(padding-top)

width: 200px


aspect-ratio
padding-top
.container{
  display: flex;
}
#box {
  border: 1px solid black;
  width: 200px;
  background: yellow;
  aspect-ratio: 1/1;
}
#box2{
  width: 200px;
}
.parent{
  position:relative;
  width:100%;
  padding-top:100%;
  overflow: hidden;
}
.parent .padding_box{
  position:absolute;
  top:0;
  left:0;
  right:0;
  bottom:0;
  width:100%;
  background:green;
}

CSS保持宽高比(aspect-ratio)VS(padding-top)_第1张图片

你可能感兴趣的:(css,css,前端,javascript)