Search code examples
htmltwitter-bootstrapbourbonneat

Bourbon Neat - uneven column count


I am trying to build a Metro-like layout, with various column widths (without using anything like Masonry), but same heights, like this:

--------------------------
| col(2)        | col(1) |
--------------------------
| col(1)| col(1)| col(1) |
--------------------------
| col(1) | col(2)        |
--------------------------

I tried to make use of various functions mentioned in the docs, but I can't get it right. My current code is as follows:

SCSS

// Config
$border-box-sizing: true !default;
$visual-grid: true !default;

// Container
.container {
    @include outer-container;
}

article.post {
    @include span-columns(4);
    height: 300px;
    background: #aaa;
}

article.large {
    @include span-columns(8);
}

HTML

<div class="container">
    <article class="post large">text</article>
    <article class="post">text</article>
    <article class="post">text</article>
    <article class="post">text</article>
    <article class="post">text</article>
    <article class="post large">text</article>
    <article class="post">text</article>
    <article class="post">text</article>
    <article class="post large">text</article>
</div>

Nothing fancy, as you see. What can I do to work this out (other than going back to Bootstrap:))?


Solution

  • You need to use @include omega(); to get the line break.

    http://thoughtbot.github.io/neat-docs/latest/#omega

    So since you want to have a break after each 12 span-cloumns, you need to add the omega there.

    In your given example it could look like this.

    Add this scss:

    article.break {   @include omega(); }
    

    And change your html to:

    <div class="container">
        <article class="post large">text</article>
        <article class="post break">text</article>
        <article class="post">text</article>
        <article class="post">text</article>
        <article class="post break">text</article>
        <article class="post large">text</article>
        <article class="post break">text</article>
        <article class="post">text</article>
        <article class="post large break">text</article>
    </div>