Giter Site home page Giter Site logo

greed's Introduction

greed

LESS-generated fluid grid system

Greed is meant to be used as a LESS mixin :

// You use this, right ?
// http://www.paulirish.com/2012/box-sizing-border-box-ftw/
* {
    -webkit-box-sizing: border-box;
    -moz-box-sizing: border-box;
    box-sizing: border-box;
}

.greed(12, 10px); // amount of columns (default : 12), gutter size (default : 0)

This will add rules to your stylesheet. Read on to see how to use them !

Usage

<div class="greed">
    <div class="row-4"> <!-- row of 4 columns -->
        <div class="col-1"></div> <!-- single column -->
        <div class="col-3"></div> <!-- triple column -->
    </div>
</div>

In this example, we declare a single 4 column-wide row, which we fill with one "normally-sized" column, and another which has thrice the width of its predecessor. If the .greed container is your main grid, it means the first column will be 25% wide and the second... yeah, right, 75%.

This also means you can easily alternate different types of columns :

<div class="greed">
    <div class="row-7">
        <div class="col-3"></div>
        <div class="col-4"></div>
    </div>
    <div class="row-11">
        <div class="col-5"></div>
        <div class="col-6"></div>
    </div>
</div>

The maximum amount of columns (and the maximum digit on the .row-* blocks) logically being the one you specified when initializing the mixin.

The columns stand beside each other by being applied the display: inline-block rule, which means their alignment can easily be modified. Use the .row-left, .row-center and .row-right classes on the .row-* blocks to do so.

It implies the use of a kinda ugly font-size: 0; hack to collapse the gap between the columns. The font-size property is restored to 1rem on the row's children. If you want to avoid this because you collapsed the spaces in your HTML, you can add the .no-hack class to the .greed container.

Responsive

With a grid system this flexible, it was pretty hard to define fixed breakpoints, so I did not. It's up to you to decide what to do about it, with rules such as :

@media query screen and (min-width: 9001px) { // OVER NINE THOUSAND
    .row-X {
        .col-Y {
            .to-row;
        }
    }
}

This rule sets display: block; and width: 100%; to the target .col-* blocks.

Enjoy !

Feel free to contribute to this.

greed's People

Contributors

neemzy avatar

Stargazers

Shane Brunson avatar Antonio Gómez-Maldonado avatar

Watchers

James Cloos avatar  avatar  avatar

Forkers

seanja

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.