I tried to align my articles on a simple grid with Bourbon Neat.
The html:
<body>
<section>
<article>1</article>
<article>2</article>
<article>3</article>
<article>4</article>
<article>5</article> <!-- << comment this to solve the problem -->
</section>
</body>
The scss:
@import "neat";
section {
@include outer-container;
article { @include span-columns(3); }
}
The CodePen example.
As you can see, the fourth and fifth articles are sent to the next row.
When the fifth article is commented, the fourth article correctly remains on the first row.
How can I get rows of four articles?
Short answer
You have to remove the right margin of the last item of a row. In Neat, you can use
omega()
for this purpose:Working CodePen.
Long answer
The last article in a section has no
margin-right
.When you have 5 articles in a section the 4th is not the last, so it gets a margin, which forces it on to the next row. When you remove the 5th the 4th becomes the last, its margin is removed, which lets it fit on the row.
You can remove the margin on the 4th article like this:
This might be problematic if you want many rows of 4 articles. What might be better is changing your HTML markup...