要居中的元素C没有width属性及height属性

第二种

by panxiaoxian

HTML

<div id='father'>
  <div id='son'>
    潘小闲 潘小闲
  </div>
</div>

CSS

#father {
  background-color: red;
  display: flex;
  height: 80px;
}

#son {
  background-color: yellow;
  margin: auto;
}