Hagrid
Contents:
- Install
- Use
- Options
- Modifiers
- Mixins
- Auto Grids
- Browser Support
- Prefixes
- Developing
- Credit & License
Install:
bower install hagrid
npm install hagrid
;
Use:
// * Initialize a basic grid .parent // * Initialize a grid-item with a set of responsive widths .item
Options:
// * Specify gutters between items. They are used like modifiers or applied to all grids // * If $layout-gutters exists it will be used instead (so you don't have to modify this file directly) ; // * Set common breakpoints used in your project. Can be used in the @bp-mixin (see below) // * If $layout-breakpoints exists it will be used instead (so you don't have to modify this file directly) ; // * Gutters and modifiers are applied to all items of each grid-container // * By default, the selector `> *` is used. If you use a consistent selector for grid-items, you can set it here ;
Modifiers:
// * Modifiers are set on grids
x-axis Alignment:
- right: Align grid-items to the right in partially filled rows.
- center: Center grid-items in partially filled rows.
- space-around: Distribute items in partially filled rows by using variable space around them.
- space-between: Distribute items in partially filled rows by using variable space between them.
y-axis Alignment:
- bottom: Align items to the bottom of the grid.
- middle: Vertically center grid items.
Spacing:
You can provide custom gutters to the grid via the config-variable
$hagrid-gutters
. Use them as you would use a normal modifier. (e.g.@include g(wide)
)
Direction:
- rev: Reverted grid on x-axis.
- flip: Reverted grid on y-axis.
Mixins:
- bp: Use breakpoints directly in a class.
- stretch: Assign stretch-mixin to a group of grid-items in a grid to stretch-align their contents.
Example (bp):
.item
Example (stretch):
.stretch // Stretch accepts a selector as parameter, it defaults to "> *" .stretch
Auto Grids:
Starting in v3.0.0, you can let flexbox work out the grid for you - on any breakpoint - by passing auto
to the i
-mixin.
Example (Auto Grids):
// Basic automatic grid .auto .auto-item // Pinned elements will keep their width - while their surrounding elements change. .auto-pinned .auto-item--pinned .auto-item // You can use automatic grids on any breakpoint you like .auto--responsive .auto-item--responsive
Browser Support:
- Chrome
- Firefox
- Safari 6.1+
- Android 4.4+
- IE 10+
- Opera 12+
If you need support for older browsers, you can use the 2.x
version range of hagrid. You can install it by running:
npm install hagrid@2.0.2
bower install hagrid@2.0.2
Prefixes:
Hagrid does not generate prefixes (-webkit-
,-ms-
) as it is designed to be integrated with common SASS workflows in mind (Gulp / Grunt with Autoprefixer). A sample configuration for Autoprefixer is available in the test build-file. Be careful not to set browsers in a way that generates legacy flexbox syntax!
Developing:
You can build the project with the default gulp-task. If you want to use sassdoc, you can build it by running gulp sassdoc
.
Credit:
- Started as a fork of csswizardry-grids
- Beard used in the logo by ZQ.
License:
The MIT License (MIT)
Copyright © 2016 Felix Spöttel
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.