<div class="card">
  <h1>这是我家的猫咪</h1>
  <div class="img__container">
    <img src="//www.w3cplus.com/sites/default/files/blogs/2020/2003/cat-632x475.jpg" alt="一只灰色的猫" width="632" height="475" />
  </div>
  <p>一只杂毛猫,喵喵.....</p>
</div>
body {
  width: 100vw;
  min-height: 100vh;
  
  display: flex;
  align-items: center;
  justify-content: center;

}

.card {
  padding: 2vh;
  border: 1px solid #cecece;
  border-radius: 5px;
  box-shadow: 0 0 2px rgba(#000, .25);
  width: 300px;
  resize: horizontal;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  width: 280px;
}
.img__container {
  position: relative;
  padding-bottom: 75.1582278481012%; // 475:632 › 475÷632
  height: 0;
  overflow: hidden;
  
  img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
  }
}
View Compiled

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.