Is there any solution to avoid the float and to use flexbox and make this type of layout like in my representation? I don't have any example but this picture with what I need.
I'll try to explain in words:
- This grid starts from 1025px and with 2 columns and the big red square in the right side.
- From 1100px I need 3 columns and the big red square in the right
- From 1680px I will have 4 columns and the big red square in the right.
- The position of the items must be like in my picture
- Depending of the aspect ratio, 4 items will go down with the others: 5,6,7,8 will go down with 9, 10, and so on.
- The big red must have always the same height with the first two rows.
- All the layout is fluid and responsive
I can make this very easy with FLOAT and some JS to calculate the exact same height of the first two rows and make the big red have the same but I want to use flexbox if its possible.
The code I have so far
.grid {
display: flex;
flex-direction: row;
}
.item {
width: 16%;
margin: 5px;
}
.red-box {
}
<div class="grid">
<div class="red-box">big box</div>
<div class="item">Item 1</div>
<div class="item">Item 2</div>
<div class="item">Item 3</div>
<div class="item">Item 4</div>
<div class="item">Item 5</div>
<div class="item">Item 6</div>
<div class="item">Item 7</div>
<div class="item">Item 8</div>
<div class="item">Item 9</div>
<div class="item">Item 10</div>
<div class="item">Item 11</div>
<div class="item">Item 12</div>
<div class="item">Item 13</div>
<div class="item">Item 14</div>
<div class="item">Item 15</div>
<div class="item">Item 16</div>
<div class="item">Item 17</div>
<div class="item">Item 18</div>
<div class="item">Item 19</div>
<div class="item">Item 20</div>
</div>