Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change the direction flow of CSS columns

So I have CSS like this:

#blogPosts{     -moz-column-count: 3;     -moz-column-gap: 10px;     -webkit-column-count: 3;     -webkit-column-gap: 10px;     column-count: 3;     column-gap: 10px;     width: 100%;  } 

and this creates 3 columns perfectly but when I gain another row the order seems to come out vertically like:

1,3,5 2,4,6 

Instead of what I am wanting as:

1,2,3 4,5,6 

Important!

Another important attribute I need, is that there must be a set margin between every post vertically. So for example if you look at the table above if 2 is longer than 1, the top of 4 will start y bellow 1 rather than: the height of 2 + y.


The HTML is like this:

<div id="blogPosts">     <div class="blog">Content</div>     <div class="blog">Content</div>     ... </div> 

What can I do to fix this?


I am happy for any solutions, even one that includes javascript/jquery


This is the kind of thing I am after

enter image description here

like image 967
maxisme Avatar asked May 15 '15 16:05

maxisme


People also ask

How do you change the order of columns in CSS?

Use grid-row-start , grid-row-end , grid-column-start , grid-column-end , or their shorthands, grid-row and grid-column , to set a grid item's size and location in the grid.

How do I move a column to the right CSS?

To move columns to the right, use the . col-*-offset-* class in Bootstrap.


1 Answers

The closest thing would be to use flexbox

#blogPosts {    display: flex;    align-items: left;    justify-content: left;    flex-direction: row;    flex-wrap: wrap;    flex-flow: row wrap;    align-content: flex-end; } 

http://jsfiddle.net/o59gc4hw/2/

like image 103
Miguel Mota Avatar answered Sep 28 '22 03:09

Miguel Mota