pogend
pogend
发布于 1周前

css 图片宽度 100% ,宽高 1:1

<div class="image-box">
  <img src=".avatar.png"/>
</div>

.image-box {
  position: relative;
  width: 100%;
  height: 0;
  padding-bottom: 100%;
  img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
  }
}
CSS