0

I'm trying to create a 3 div layout like this:

enter image description here

So that I could then place an image inside the left div, then place 1 paragraph inside the top right div and 1 paragraph in the bottom right div.

I'm having some trouble figuring how to do this using flexbox. The way I see it I would need like 5 divs and something like this.

<div class='flexbox'>
    <div class='container-one'></div>
    <div class='container-two'>
        <div>
            <p></p>
        </div>
        <div>
            <p></p>
        </div>
    </div>
</div>

.flexbox {
    display: flex;
}
.container-one {
    flex: 1;
}
.container-two {
    flex: 4;
    display: flex;
    flex-direction: column
}

Would that be the correct way of doing this? It does use quite a lot of divs and maybe it could be done with less.

Onyx
  • 5,186
  • 8
  • 39
  • 86

2 Answers2

1

You don't really need too much containers.

.flexbox {
  position: relative;
  display: flex;
  flex-flow: column wrap;
  background: #0c8ec4;
  height: 60vh;
  padding: 1rem 0 0 1rem;
}

.flexbox div:first-child {
  min-width: 20%;
  flex: 1 0 65%;
}

.flexbox div,
.flexbox div:last-child {
  flex: 1 0 25%;
  min-width: 70%;
  background: #fff;
  margin: 0 1rem 1rem 0;
}
<div class='flexbox'>
  <div></div>
  <div></div>
  <div></div>
</div>
Kosh
  • 16,966
  • 2
  • 19
  • 34
0

you can do something of this sort

.flexbox{

border:1px solid black;
width:300px;
height:300px;
display:flex;
}

.container-one {
width:40%;
border-right:1px solid black;
}

.container-two {
width:100%;
 display:flex;
 flex-direction:column;

}

.container-two div{
  
   height:50%;
    
}

.container-two div:first-child{
   border-bottom:1px solid black;
}
<div class='flexbox'>
    <div class='container-one'></div>
    <div class='container-two'>
        <div>
            
        </div>
        <div>
           
        </div>
    </div>
</div>
Geeky
  • 7,420
  • 2
  • 24
  • 50