Flexbox 3 Divs, Two Columns, One With Two Rows
Solution 1:
The Legit Method: *Recommended
.flex-row {
flex-direction: row;
display: flex;
}
.flex-column {
flex-direction: column;
display: flex;
}
.flex-body {
display: flex;
}
.flex-bodydiv:not([class*="flex"]) {
border: 1px solid white;
flex: 11200px;
width: 300px;
}
<divclass="flex-body"><divclass="flex-row"><divstyle="background: #0980cc;"></div></div><divclass="flex-column"><divstyle="background: #09cc69;"></div><divstyle="background: #cc092f;"></div></div></div>
The Hackish Method: *Not Recommended (I'm sure you'll notice why)
.flex-body {
display: flex;
flex-direction: row-reverse;
flex-wrap: wrap;
justify-content: flex-end;
align-content: stretch;
align-items: stretch;
transform: rotate(90deg);
max-width: 500px;
margin: auto;
}
.flex-bodydiv {
border: 1px solid white;
height: 300px;
flex: 11200px;
}
.flex-bodydiv:last-of-type {
flex: 11300px;
height: 300px;
}
<divclass="flex-body"><divstyle="background: #0980cc;"></div><divstyle="background: #09cc69;"></div><divstyle="background: #cc092f;"></div></div>
Solution 2:
After thinking about this a little more, it is possible with flexbox. The container just has to have a defined height (%
, px
or vh
) will work.
http://codeply.com/go/U1DCKAx85d
body {
display: flex;
flex-wrap: wrap;
flex-direction: column;
height: 100vh;
}
.a {
flex: 00100%;
background: red;
}
.b, .c {
flex: 0050%;
background: green;
}
.c {
background: blue;
}
Solution 3:
Using flexbox
is very simple, you just need a container for these three div
elements.
Let's define a div with a .box
class and add the div
elements. Also let's add three classes for the colors: .red
, .green
and .blue
and two classes to handle the columns left
and right
.
<divclass="box"><divclass="left red"></div><divclass="right green"></div><divclass="right blue"></div></div>
Now we define the box
class as a flexbox:
.box {
display: flex;
...
}
Then we define the direction as column
(vertical) and if it can be flowed wrap
:
.box {
...
flex-flow: column wrap;
...
}
Also, we can define the dimensions of the div
elements. left
will be 45%
of the parent width
and 100%
of the parent height
.
.left {
width: 45%;
height: 100%;
}
While right
will be 55%
of the parent width
and 50%
(half) of the parent height
.
.right {
width: 55%;
height: 50%;
}
Full example:
.box {
display: flex;
flex-flow: column wrap;
width: 400px;
height: 100px;
}
.red {
background: #cc092f;
}
.green {
background: #09cc69;
}
.blue {
background: #0980cc;
}
.left {
width: 45%;
height: 100%;
}
.right {
width: 55%;
height: 50%;
}
<divclass="box"><divclass="left red"></div><divclass="right green"></div><divclass="right blue"></div></div>
Post a Comment for "Flexbox 3 Divs, Two Columns, One With Two Rows"