How do I build the example shown in the image below with flexbox? I don’t know enough about flexbox to get the following design to work. Please help.
<div class="container">
<div class="flex-1"></div>
<div class="flex-2"></div>
<div class="flex-3"></div>
<div class="flex-4"></div>
</div>
.container {
height: 200px;
width: 300px;
display: -webkit-flexbox;
display: -ms-flexbox;
display: -webkit-flex;
display: -moz-flex;
display: flex;
-webkit-flex-direction: row;
-moz-flex-direction: row;
-ms-flex-direction: row;
flex-direction: row;
}
.flex-1,
.flex-2,
.flex-3,
.flex-4 {
margin: 10px;
width: 100px;
height: 100px;
}
.flex-1 {
position: relative;
background-color: green;
width:200px;
margin-left:200px;
}
.flex-2 {
position: relative;
background-color: red;
flex-direction:row
}
.flex-3 {
background: orange;
width: 100px
}
.flex-4 {
background: blue;
width: 100px
}
Here is a fiddle with my futile attempt: https://jsfiddle.net/oq4m9Lha/1/
I can do this all day with CSS floats, but I’m trying to expand my horizons.
2
Answers
Here’s one example:
HTML
CSS
CODEPEN: https://codepen.io/UncleRemus/full/poQXyVg
/// EDIT: ///
Adding Solution the original poster went with (bubbling up from comments)
HTML
CSS
there are a few adjustments needed.