3

I have this code:

<div id="columns">
    <div id="box1">box1</div>
    <div id="box2">box2</div>
    <div id="box3">box3</div>
    <div id="box4">box4</div>
    <div id="box5">box5</div>
    <div id="box6">box6</div>
</div>

The css:

.column {
column-count: 3;
column-gap: 0px;
column-fill: auto;
margin: auto;
}   

#box(n) {
display: inline-block;
padding: 0 10px;
margin: 10px 10px;
}

I'm getting:

box1 box4
box2 box5
box3 box6

What I want:

box1 box2
box3 box4
box5 box6

Can anyone help me how to do it with pure html/css? I'm trying to do it pinterest style(boxes with different heights).

enter image description here

Henrique Braun
  • 321
  • 1
  • 3
  • 7

1 Answers1

2

Try using float:

Demo: http://jsfiddle.net/GCu2D/912/

HTML

<div id="columns">
    <div id="box1">box1</div>
    <div id="box2">box2</div>
    <div id="box3">box3</div>
    <div id="box4">box4</div>
    <div id="box5">box5</div>
    <div id="box6">box6</div>
</div>

CSS:

#columns {
    width:400px; /* change it according to your design*/
}
#columns div {
    float:left;
    width:50%;/*so as to give equal width to div */
    outline:1px solid red;/*optional*/
    height:400px;/*use your own value*/
}
#columns:after {
    content:"";
    display:block;
    clear:both;
}
K K
  • 17,794
  • 4
  • 30
  • 39