Giter Club home page Giter Club logo

components-grid's Introduction

SUIT CSS components-grid

Build Status

A CSS grid component. The grid makes use of inline-block and box-sizing to provide features that float-based layouts cannot.

N.B. This component relies on particular dimensions being applied to cells in the grid via other classes. For example, suitcss-utils-size.

Read more about SUIT CSS.

Installation

  • npm: npm install suitcss-components-grid
  • Component(1): component install suitcss/components-grid
  • Bower: bower install suit-components-grid
  • Download: zip

Features

  • Fluid layout.
  • Intelligent cell wrapping.
  • Horizontal centering of cells.
  • Custom vertical alignment of cells (top, bottom, or middle).
  • Cell width is controlled independently of grid gutter.
  • Infinite nesting.
  • Built-in redundancy.

Available classes

  • Grid: core component
  • Grid--alignCenter: center-align all child Grid-cell
  • Grid--alignRight: right-align all child Grid-cell
  • Grid--alignMiddle: middle-align all child Grid-cell
  • Grid--alignBottom: bottom-align all child Grid-cell
  • Grid--withGutter: adds a gutter between cells
  • Grid-cell: a child cell of Grid that wraps grid content
  • Grid-cell--center: center an individual Grid-cell

Configurable variables

  • --Grid-font-size: the font-size to use within the Grid (defaults to 1rem).
  • --Grid-gutter-size: the width of the gutter applied by the Grid--withGutter modifier class.

Use

A simple grid is easy to create. A grid container can have any number of child cells.

<div class="Grid [Grid--alignCenter|Grid--alignRight|Grid--alignMiddle|Grid--alignBottom]">
  <div class="Grid-cell u-size1of2 u-lg-size6of12"></div>
  <div class="Grid-cell u-size1of2 u-lg-size4of12"></div>
  <div class="Grid-cell u-size1of3 u-lg-size2of12"></div>
  <div class="Grid-cell u-size1of3"></div>
</div>

Widths and offsets

Cell widths and offsets can be controlled using the responsive sizing utilities and responsive offset utilities, respectively.

One limitation of creating grid gutters in the manner shown above is that it prevents any offset utilities applied directly to the Grid component from functioning as expected.

GOOD:

<div class="Grid Grid--withGutter">
  <div class="Grid-cell u-size1of2 u-before1of4 u-after1of4">
    {{>partial}}
  </div>
</div>

BAD:

<div class="Grid Grid--withGutter u-before1of4 u-after1of4">
  <div class="Grid-cell">
    {{>partial}}
  </div>
</div>

You can nest grids in any context, including one that uses dimension or offset utilities, but keep in mind that the the dimensions will be relative to the grid's width, and not the width of the whole application.

<div class="u-before1of4 u-after1of4">
  <div class="Grid Grid--withGutter">
    <div class="Grid-cell u-size1of2"> <!-- 50% of the width of the Grid -->
      {{>partial}}
    </div>
  </div>
</div>

Testing

Install Node (comes with npm).

npm install

To generate a build:

npm run build

To generate the testing build.

npm run build-test

Basic visual tests are in test/index.html.

Browser support

  • Google Chrome (latest)
  • Opera (latest)
  • Firefox 4+
  • Safari 5+
  • Internet Explorer 9+

components-grid's People

Watchers

 avatar  avatar

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.