我有一个带display: flex
的div,我想在行中心显示输出。由于某种原因,它向左显示。我希望imgBoxBot
在imgBot
div
内居中。但是text-align: center
只是将文本居中imgBoxBot
,我如何居中实际div
?
#imgBot {
position: absolute;
height: 100px;
width: 100%;
bottom: 0;
display: flex;
flex-direction: row;
text-align: center;
}
#imgBoxBot {
height: 100px;
width: 100px;
}
<div id="imgBot">
<div id="imgBoxBot">
test
</div>
<div id="imgBoxBot">
test
</div>
</div>
使用justify-content: center
.您可以在此处找到更多信息
#imgBot {
position: absolute;
height: 100px;
width: 100%;
bottom: 0;
display: flex;
flex-direction: row;
justify-content: center;
}
.imgBoxBot {
height: 100px;
width: 100px;
}
<div id="imgBot">
<div class="imgBoxBot">
test
</div>
<div class="imgBoxBot">
test
</div>
</div>