首页 > 解决方案 > 使 div 的高度等于 flex 容器中内容的高度

问题描述

如何使子 div 的高度仅与内容(在这种情况下为文本)一样长?

.wrapp{
  display:flex;
  flex-direction: row;
  flex-wrap: wrap;
  height: 1200px;
}

.child{
  border: 1px solid red;
  width: 50px;
  height: auto;
  margin: 20px
}
<div class='wrapp'>
<div class='child'>text text text texttext texttext texttext texttext texttext texttext texttext texttext texttext text</div>
<div class='child'>text texttext text</div>


</div>

标签: htmlcssflexbox

解决方案


推荐阅读