HTML:
<div class="flex">
<span>One</span>
<span>two</span>
<span>three</span>
<span class="four">four</span>
<span>five</span>
</div>
CSS:
.flex {
display: flex;
flex-direction: column;
justify-content: center;
}
span {
background: #999;
margin-top:10px;
}
.four {
background: #FFFF00;
}
基本上标题是这样的 - 我如何在一行中内联.four
和.five
spans
?它甚至可能吗?有什么想法吗?
答案 0 :(得分:1)
您必须使用flex-direction: row
然后在flex-container上设置flex-wrap: wrap
,并在除第4和第5之外的所有范围设置flex: 0 0 100%
。
.flex {
display: flex;
flex-wrap: wrap;
}
span {
background: #999;
margin-top:10px;
flex: 0 0 100%;
}
span:nth-child(4),
span:nth-child(5) {
flex: 0 0 50%;
}
.four {
background: #FFFF00;
}
&#13;
<div class="flex">
<span>One</span>
<span>two</span>
<span>three</span>
<span class="four">four</span>
<span>five</span>
</div>
&#13;
答案 1 :(得分:0)
我试了一下
.flexC {
display: flex;
flex-direction: column;
}
.flexR {
display: flex;
flex-direction: row;
}
.flexR span {
width: 50%;
}
span {
background: #999;
margin-top: 10px;
}
.four {
background: #FFFF00;
}
<div class="flexs">
<div class="flexC">
<span>One</span>
<span>two</span>
<span>three</span>
</div>
<div class="flexR">
<span class="four">four</span>
<span>five</span>
</div>
</div>