<div class="flexbox">
<div class="1"></div>
<div class="2"></div>
<div class="3"></div>
<div class="4"></div>
<div class="5"></div>
</div>
.flexbox{
height:500px;
width:500px;
}
I want something like this https://awwapp.com/s/b6c9c247-2dba-4ec9-a47d-1f165679ba03/
I cant change my structure . i want a solution with flexbox.
Order of div dosent matter much as long as they have same one parent.
I tried using flex:wrap
. with width,height = 50% of two divs and width ,height = 50%,33.3% of rest three but it gave me somthing like https://awwapp.com/s/237968ae-c13f-4d0d-bab2-07024486b3c4/
.
Can anyone Help me out ?
Approach: To create a two-column layout, first we create a <div> element with property display: flex, it makes that a div flexbox and then add flex-direction: row, to make the layout column-wise. Then add the required div inside the above div with require width and they all will come as columns.
Flexbox was designed as a single dimensional layout, meaning that it deals with laying out items as a row or as a column — but not both at once. There is however the ability to wrap flex items onto new lines, creating new rows if flex-direction is row and new columns if flex-direction is column .
The basic difference between CSS Grid Layout and CSS Flexbox Layout is that flexbox was designed for layout in one dimension - either a row or a column. Grid was designed for two-dimensional layout - rows, and columns at the same time.
Nested flex boxesIt's possible to create some pretty complex layouts with flexbox. It's perfectly OK to set a flex item to also be a flex container, so that its children are also laid out like flexible boxes.
Hope this will be the solution four your problem
.flexbox{
height: 500px;
width: 500px;
display: flex;
flex-direction: column;
justify-content: space-between;
flex-wrap: wrap;
}
.flexbox div {
width: 40%;
background: green;
height: 30%;
}
.flexbox .one, .flexbox .two{
height: 45%;
}
<div class="flexbox">
<div class="one">one</div>
<div class="two">two</div>
<div class="three">three</div>
<div class="four">four</div>
<div class="five">five</div>
</div>
Here is the working jsFiddle demo.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With