是否可以将带有项目显示的flex元素设为行,但是2个项目显示为列?
我想像这样显示
.nav{
height: 44px;
border: 1px solid #000;
display: flex;
flex-direction: row;
}
.item{
text-decoration: none;
border: 1px solid #000;
width: 60px;
text-align: center;
}
.item.inline{
background: lightcoral;
height: 20px;
}
**HTML:**
<div class="nav">
<a href="#" class="item">1</a>
<a href="#" class="item">2</a>
<a href="#" class="item">3</a>
<a href="#" class="item inline">4</a>
<a href="#" class="item inline">5</a>
<a href="#" class="item">6</a>
</div>
答案 0 :(得分:2)
包裹的列,看起来像一行:
.nav, .item {
box-sizing: border-box;
border: 1px solid #000;
}
.nav {
display: flex;
flex-flow: column wrap;
align-content: flex-start;
height: 44px;
}
.item {
width: 60px;
height: 100%;
text-align: center;
text-decoration: none;
}
.item.inline {
background: lightcoral;
height: 50%;
}
<div class="nav">
<a href="#" class="item">1</a>
<a href="#" class="item">2</a>
<a href="#" class="item">3</a>
<a href="#" class="item inline">4</a>
<a href="#" class="item inline">5</a>
<a href="#" class="item">6</a>
</div>