Reputation: 604
a need to arrange three small elements in one column besides big one.
sample html:
<div class="container">
<div class="big_element"></div>
<div class="small_element"></div>
<div class="small_element"></div>
<div class="small_element"></div>
</div>
and the CSS:
.container {
display: flex;
flex-direction: row; width: 496px;
}
.big_element, .small_element {
display: flex;
width: 248px;
}
Upvotes: 3
Views: 3326
Reputation: 1283
There is many ways but I think the best two ways are either using TABLE instead of DIVs or by Flexbox:
Using table:
table{
height: 200px;
width: 200px;
border: 0;
}
tr{
border: 1px black solid;
}
<table border="1" cellpadding="0" cellspacing="10px">
<tr>
<td rowspan="3"></td><td></td>
</tr>
<tr>
<td></td>
</tr>
<tr>
<td></td>
</tr>
</table>
Flexbox:
.wrapper {
display: -webkit-flex;
display: flex;
-webkit-flex-flow: column wrap; /* Safari 6.1+ */
flex-flow: column wrap;
font-weight: bold;
text-align: center;
height: 200px;
width: 200px;
padding: 5px;
}
.wrapper > div{
border: 1px black solid;
-webkit-flex-grow: 1;
flex-grow: 1;
margin: 5px;
}
.left{
-webkit-flex-basis: 100%;
flex-basis: 100%;
}
<div class="wrapper">
<div class="left"> </div>
<div class="aside"> </div>
<div class="aside"> </div>
<div class="aside"> </div>
</div>
Upvotes: 1
Reputation: 122095
You can do this with nested Flexbox
body, html {
margin: 0;
padding: 0;
}
.container {
display: flex;
min-height: 100vh;
}
.big_element, .small_element {
border: 1px solid black;
padding: 10px;
margin: 5px;
flex: 1;
}
.right {
display: flex;
flex: 1;
flex-direction: column;
}
<div class="container">
<div class="big_element"></div>
<div class="right">
<div class="small_element"></div>
<div class="small_element"></div>
<div class="small_element"></div>
</div>
</div>
Upvotes: 2