<分区>
<分区>
我有这个标记
.course-flex-container {
display: flex;
flex-direction: column;
margin: 5px 5px 5px 5px;
background-color: red;
}
.course-flex-row {
display: flex;
flex-direction: row;
justify-content: space-between;
}
.course-flex-row-2 {
display: flex;
flex-direction: row;
}
<div class="course-flex-container">
<div class="course-flex-row">
<div>edit</div>
<div>delete</div>
</div>
<div class="course-flex-row-2">
<div>Read Chapter 1 to 3</div>
</div>
<div class="course-flex-row">
<div>Blaw 3100</div>
<div>Due Date: 6/29/2017</div>
</div>
</div>
我试图对齐 <div>Read Chapter 1 to 3</div>
但是当我使用 text-align: center;
时它不会居中对齐我试过那个 div
和它的 parent div
.
我删除了 text-align
来 self 的代码,因为它无法正常工作,这就是您看不到它的原因。
最佳答案
使用justify-content: center
到.course-flex-row-2
.course-flex-container {
display: flex;
flex-direction: column;
margin: 5px 5px 5px 5px;
background-color: red;
}
.course-flex-row {
display: flex;
flex-direction: row;
justify-content: space-between;
}
.course-flex-row-2 {
display: flex;
flex-direction: row;
justify-content: center;
}
<div class="course-flex-container">
<div class="course-flex-row">
<div>edit</div>
<div>delete</div>
</div>
<div class="course-flex-row-2">
<div>Read Chapter 1 to 3</div>
</div>
<div class="course-flex-row">
<div>Blaw 3100</div>
<div>Due Date: 6/29/2017</div>
</div>
</div>
关于html - 如何让这个div居中对齐?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44851692/
相关文章:
javascript - 需要居中整个导航栏,包括子菜单,找不到正确的代码。我的 JavaScript 搞砸了吗?
javascript - 使用 JQuery 设置 CSS 关键帧
.net - @font-face 在本地主机上工作正常,但在 AppHarbor 中不行
html - 带有几个方 block 的 Flexbox 任务和 @media 变化低于 600px
javascript - 如何使用 socket.io 包含外部 javascript 客户端?
javascript - jQuery如何设置点击div中的href?