找不到为什么.user-name-box
& .user-location
div不想留在父母的中心......
.main-content{
display: flex;
flex-flow: row nowrap;
justify-content: center;
align-items: center;
width: 600px;
background: grey;
}
.user-info{
display: inline-flex;
flex-flow: column nowrap;
justify-content: center;
align-content: center;
width: 300px;
background: red;
}
.user-name-box{
display: flex;
width: 100px;
height: 100px;
background: blue;
color: white;
}
.user-location{
display: flex;
width: 100px;
height: 100px;
background: yellow;
color: black;
}
<div class="main-content">
<div class="user-info">
<div class="user-name-box">user-name-box</div>
<div class="user-location">user-location</div>
</div>
</div>
提前致谢!
答案 0 :(得分:1)
这是因为您在align-content
上使用的是align-items
而不是.user-info
。
.main-content {
display: flex;
flex-flow: row nowrap;
justify-content: center;
align-items: center;
width: 600px;
background: grey;
}
.user-info {
display: inline-flex;
flex-flow: column nowrap;
justify-content: center;
align-items: center;
width: 300px;
background: red;
}
.user-name-box {
display: flex;
width: 100px;
height: 100px;
background: blue;
color: white;
}
.user-location {
display: flex;
width: 100px;
height: 100px;
background: yellow;
color: black;
}
&#13;
<div class="main-content">
<div class="user-info">
<div class="user-name-box">user-name-box</div>
<div class="user-location">user-location</div>
</div>
</div>
&#13;