我想要左边的ABCD,DATE应该在中心。怎么做到这一点?
.flex-items {
display: flex;
justify-content: flex-start;
padding-left: 17px;
}
.abcd1 {}
.date1 {
/*this item should be in the center.*/
}

<div class="flex-items">
<div class="abcd1">ABCD</div>
<div class="date1">DATE</div>
</div>
&#13;
答案 0 :(得分:3)
试试此代码
.flex-items {
display: flex;
justify-content: flex-start;
padding-left: 17px;
}
.abcd1 {
}
.date1 {
margin-left: auto;
margin-right: auto;
}
&#13;
<div class="flex-items">
<div class="abcd1">ABCD</div>
<div class="date1">DATE</div>
</div>
&#13;
答案 1 :(得分:0)
见下文。希望这会有所帮助。
.flex-items {
display: flex;
padding-left: 17px;
text-align: center;
}
.date1 {
flex: 1;
}
&#13;
<div class="flex-items">
<div class="abcd1">ABCD</div>
<div class="date1">DATE</div>
</div>
&#13;
答案 2 :(得分:0)
文字对齐:中心在提供宽度时有效。 这也有效:
.flex-items {
display: flex;
justify-content: flex-start;
padding-left: 17px;
}
.abcd1 {
}
.date1 {
/*this item should be in the center.*/
text-align: center;
width: 100%;
}
&#13;
<div class="flex-items">
<div class="abcd1">ABCD</div>
<div class="date1">DATE</div>
</div>
&#13;