Fah*_*eri 3 html css css3 flexbox
我使用Flexbox的对齐的div,我想使双方postavatar
并userinfo
在左侧posttime
是对的。
.postheader {
display: flex;
justify-content: space-between;
}
.postheader .postavatar img {
width: 90px;
}
.postheader .userinfo {
margin-top: 10px;
margin-left: 20px;
}
.postheader .userinfo .postusername {
color: #b3b3b3;
}
.postheader .posttime {
color: #b3b3b3;
}
Run Code Online (Sandbox Code Playgroud)
<div class="postheader">
<div class="postavatar"><img src="images/avatar01.png" alt="User Image"></div>
<div class="userinfo">
<div class="postfullname">Fahad Aldaferi</div>
<div class="postusername">@Q8Xbox</div>
</div>
<div class="posttime">24 m</div>
</div>
Run Code Online (Sandbox Code Playgroud)
您可以简单地justify-content: space-between;
从flex容器中删除,然后添加margin-left: auto;
最后一个flex项目。
.postheader {
display: flex;
/*justify-content: space-between;*/
}
.postheader .postavatar img {
width: 90px;
}
.postheader .userinfo {
margin-top: 10px;
margin-left: 20px;
}
.postheader .userinfo .postusername {
color: #b3b3b3;
}
.postheader .posttime {
color: #b3b3b3;
margin-left: auto; /*new*/
}
Run Code Online (Sandbox Code Playgroud)
<div class="postheader">
<div class="postavatar"><img src="images/avatar01.png" alt="User Image"></div>
<div class="userinfo">
<div class="postfullname">Fahad Aldaferi</div>
<div class="postusername">@Q8Xbox</div>
</div>
<div class="posttime">24 m</div>
</div>
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
3340 次 |
最近记录: |