0

I have a lot of box of different height and i would like to have this result:

Box result expected

But box are aligned relative to the biggest box height. I add this to container but size line is the bigger element.

display: flex;
margin: 9px;
flex-wrap: wrap;

Demo

Asons
  • 84,923
  • 12
  • 110
  • 165
Dooxe
  • 11
  • 5

1 Answers1

1

This is little approach from modern grid layout. If you try you can manipulate grid row and column easily! Here is an example....

html {
  box-sizing: border-box;
}

*,
*:before,
*:after {
  box-sizing: inherit;
}

body {
  margin: 40px;
}

.wrapper {
  margin: 0 0 20px 0;
  width: 500px;
  height: 400px;
  display: grid;
  grid-gap: 10px;
  grid-template-columns: repeat(6, 1fr);
  grid-template-rows: repeat(3, 100px);
  justify-content: center;
  align-content: end;
}

.box {
  background-color: #444;
  color: #fff;
  border-radius: 5px;
  padding: 20px;
  font-size: 150%;
}

.item1 {
  grid-column: 1 / 3;
  grid-row: 1/3;
}

.item2 {
  grid-column: 1 / 3;
  grid-row: 3 / 4;
}

.item3 {
  grid-column: 3 / 5;
}

.item4 {
  grid-column: 3 / 5;
  grid-row: 2/4;
}

.item5 {
  grid-column: 5 / 7;
  grid-row: 1/ 3;
}

.item6 {
  grid-column: 5 / 7;
  grid-row: 3/ 4;
}
<div class="wrapper">
  <div class="box item1">One</div>
  <div class="box item2">Two</div>
  <div class="box item3">Three</div>
  <div class="box item4">Four</div>
  <div class="box item5">Five</div>
  <div class="box item6">Six</div>
</div>
Momin
  • 3,200
  • 3
  • 30
  • 48