html - Flexbox - 5 columns in first row and 6 columns in second row -
i have layout that's using flexbox , trying figure out how break 11 elements 2 rows. place i'm having issues breaking out elements 2 rows first row has 5 columns , second row has 6 columns 11 elements same width. this:
here's have far:
.container { display:flex; flex-wrap:wrap; justify-content:space-around; } .ele { flex-grow:1; height:100px; width:calc(100% * (1/6) - 2px); border:1px solid black; }
<div class="container"> <div class="ele">element</div> <div class="ele">element</div> <div class="ele">element</div> <div class="ele">element</div> <div class="ele">element</div> <div class="ele">element</div> <div class="ele">element</div> <div class="ele">element</div> <div class="ele">element</div> <div class="ele">element</div> <div class="ele">element</div> </div>
what can make use of pseudo elements.
here positioned ::before
before 1st ele
, ::after
after 5th ele
(using order
property), made them half width of ele
, push last 6 next row , @ same time center first 5.
.container { display:flex; flex-wrap:wrap; justify-content:space-around; } .ele { height:100px; flex-basis: calc(100% / 6); border:1px solid black; box-sizing: border-box; } .container::after, .container::before { content: ''; flex-basis: calc(100% / 12); } .container::after { order: 1; } .ele:nth-child(n+6) { order: 2; }
<div class="container"> <div class="ele">element</div> <div class="ele">element</div> <div class="ele">element</div> <div class="ele">element</div> <div class="ele">element</div> <div class="ele">element</div> <div class="ele">element</div> <div class="ele">element</div> <div class="ele">element</div> <div class="ele">element</div> <div class="ele">element</div> </div>
Comments
Post a Comment