2 回答
TA贡献1725条经验 获得超7个赞
flex-basis:0为了确保元素真正共享可用空间,而不是先计算每个弹性项目的内容,然后分配剩余空间。
剩下的只是简单的对齐。
flex: 1 0 0;是缩写
flex-grow:1; // make element grow
flex-shrink:0; // prevent element from shrinking (preference really)
flex-basis:0; // ignore content width
/* Just for illustrating, To be removed */
body * {
border: 1px solid;
padding: 10px;
}
[center] {
display: flex;
flex-direction: column;
align-items: center;
margin: 1.5rem;
}
/* ============ */
.flex {
display: flex;
}
.page-container {
margin: 1.5rem;
max-height: 9rem;
overflow: hidden;
align-items: center;
}
.team-name {
flex: 1 0 0;
align-items: center;
justify-content: flex-end;
}
.team-logo {
max-height: 6rem;
max-width: 7rem;
overflow: hidden;
margin: 0 10px;
}
.vs {
margin: 0 10px;
}
.team-name~.team-name {
justify-content: flex-start;
}
True center example
<div center="">
<div>VS</div>
</div>
<div class="flex page-container">
<div class="flex team-name">
THIS TEAM NAME IS LONG
<img class="team-logo" src="https://i.picsum.photos/id/163/200/300.jpg">
</div>
<div class="vs">VS</div>
<div class="flex team-name">
<img class="team-logo" src="https://i.picsum.photos/id/163/200/300.jpg"> SHORT NAME
</div>
</div>
TA贡献1836条经验 获得超4个赞
尝试
.page-container {
justify-content: space-between;
}
或者
.page-container {
justify-content: space-evenly;
}
如果您不希望团队名称与边缘对齐
- 2 回答
- 0 关注
- 111 浏览
添加回答
举报