我想修改.flexrow
div的宽度内容,但我无法使用flex进行设置。如何使div的宽度适应flexbox的内容
HTML
<div class="fullwidth">
<div class="sidebar">
<p>sidebar</p>
<p>sidebar</p>
<p>sidebar</p>
<p>sidebar</p>
<p>sidebar</p>
<p>sidebar</p>
</div>
<div class="center">
<div class="flexrow">
<div class="card">
<p>card</p>
</div>
</div>
</div>
</div>
CSS
.center {
display: flex;
justify-content: center;
}
.flexrow {
display: inline-flex;
flex-direction: row;
flex-wrap: wrap;
}
.flexrow .card {
width: 300px;
height: 60px;
background-color: red;
margin: 10px;
padding: 10px;
text-align: center;
}
我创建了一个片段here
什么建议吗?
div'你指的是哪一个'? – sol
你想达到什么目的?每个红色块只与其中的文本一样宽? –
对不起,我想对齐'.flexrow' div – SaroVin