-1

I have more than 3 child nodes and a single parent div. I want to align the div like a bricks. But the div is not positioning properly. The child's consuming unwanted space at bottom in between two div's.

Each child div have different heights, so display: flex property is not effective in the parent. Also tried with column-count property in the parent div and it's not working properly in chrome.

See the Demo

.container {
  border: 1px black solid;
  overflow: hidden;
  vertical-align: top;
}

.small {
  float: left;
  width: 100px;
  border: 1px black solid;
  background: aliceblue;
}
<div class="container">
  <div class="small">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry.</div>
  <div class="small">It has survived not only five centuries.</div>
  <div class="small">It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout.</div>
  <div class="small">more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum</div>
  <div class="small">Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical.</div>
  <div class="small">Latin literature from 45 BC, making it over 2000 years old.</div>
  <div class="small">The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested.</div>
</div>
Paolo Forgia
  • 6,572
  • 8
  • 46
  • 58
Vimal
  • 2,767
  • 3
  • 19
  • 24

3 Answers3

1

You can use CSS-Masonry layout. See this link: http://w3bits.com/css-masonry/

Paolo Forgia
  • 6,572
  • 8
  • 46
  • 58
bellabelle
  • 908
  • 7
  • 13
0

Try this it should work

.container{
  border: 1px black solid;  
  overflow: hidden;  
  vertical-align: top;
  display:flex;
}

.small{
  float: left;
  width: 100px;
  border: 1px black solid;
  background: aliceblue;
  align-self: center;
}

http://jsfiddle.net/8g9cycs8/

Hassan ALAMI
  • 318
  • 1
  • 5
  • 18
0

Please use flex box it will solve the problem very easily.

.Container {
    display: flex;
    justify-content: flex-start;
}
Serge K.
  • 5,303
  • 1
  • 20
  • 27
janaravi
  • 106
  • 1
  • 8