我有一个很长的列表,子项目属于同一类别。随着子菜单的增长,我希望子菜单在3列中列出子菜单项时突破。有谁知道如何做到这一点的技巧?
见这里说明了我的问题:
topmenu item
-submenu 1
-submenu 2
-submenu 3
-submenu 4
-submenu 5
-submenu 6
-submenu 7
-submenu 8
-submenu 9
-submenu 10
-submenu 11
-submenu 12
-submenu 13
-submenu 14
-submenu 15
-submenu 16
-submenu 17
-submenu 18
-submenu 19
-submenu 20
我需要它像这样:
topmenu item
-submenu 1 -submenu 6 -submenu 11
-submenu 2 -submenu 7 -submenu 12
-submenu 3 -submenu 8 -submenu 13
-submenu 4 -submenu 9 -submenu 14
-submenu 5 -submenu 10 -submenu 15
感谢
答案 0 :(得分:0)
您可以使用flexbox执行此操作
5 items demo | 10 items demo |的 15 items demo 强>
<div class="container">
<div class="item">1</div>
<div class="item">2</div>
<div class="item">3</div>
<div class="item">4</div>
<div class="item">5</div>
<div class="item">6</div>
<div class="item">7</div>
<div class="item">8</div>
<div class="item">9</div>
<div class="item">10</div>
<div class="item">11</div>
<div class="item">12</div>
<div class="item">13</div>
<div class="item">14</div>
<div class="item">15</div>
</div>
.container{
max-height: 200px;
width: 100%;
display: flex;
flex-direction: column;
flex-wrap: wrap;
color: #fff;
justify-content: flex-start;
align-content: flex-start;
align-items: flex-start;
}
.item{
height: 20px;
background: maroon;
width: 200px;
margin: 3px;
padding: 5px;
}
答案 1 :(得分:0)
您可以使用CSS3 columns module。
<div class="container">
<div class="child">1</div>
<div class="child">2</div>
<div class="child">3</div>
<div class="child">4</div>
<div class="child">5</div>
<div class="child">6</div>
<div class="child">7</div>
</div>
.container {
-webkit-column-count: 3;
-moz-column-count: 3;
column-count: 3;
}