Skip to content

Commit fa81e90

Browse files
author
Cory Simmons
committed
4.0.0
1 parent c2d7dd4 commit fa81e90

File tree

3 files changed

+398
-457
lines changed

3 files changed

+398
-457
lines changed

README.md

Lines changed: 34 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,15 @@
88
<img src="http://img.shields.io/npm/dm/lost-grid.svg?style=flat-square">
99
</p>
1010

11-
Lost Grid is a grid system for SCSS or Stylus. It is built upon years of studying grid systems and building dozens of grid systems with tons of community feedback.
11+
Lost Grid is a grid system for SCSS or Stylus. It is built upon years of studying and [building](http://jeet.gs) grid systems with **tons** of community feedback.
1212

13-
It makes use of [`calc()`](http://caniuse.com/#feat=calc) to create stunning grids based on fractions you define.
13+
It makes use of [`calc()`](https://webdesign.tutsplus.com/tutorials/calc-grids-are-the-best-grids--cms-22902) to create stunning grids based on fractions you define.
14+
15+
I can tell you with no ego, this is [my finest grid](https://www.youtube.com/watch?v=EnjtQQQaDKo).
1416

1517

1618
## Better than X
17-
Lost is better than any grid system out there and it can prove it.
19+
Lost is better than any grid system out there and can prove it.
1820

1921
Feature | Lost | [Bootstrap](http://getbootstrap.com/css/#grid) | [Foundation](http://foundation.zurb.com/grid.html) | [Jeet](http://jeet.gs/) | [Neat](http://neat.bourbon.io/) | [Susy](http://susy.oddbird.net/)
2022
:-:|:-:|:-:|:-:|:-:|:-:|:-:
@@ -39,7 +41,7 @@ Feature | Lost | [Bootstrap](http://getbootstrap.com/css/#grid) | [Foundation](h
3941

4042
## Getting Started
4143

42-
Lost works by creating **blocks**. Think of these blocks as columns in a traditional grid system, except they can go vertical as well. To create a basic horizontal grid, just insert some blocks into an element like so and pass a fraction (**as a string**) to `block()`.
44+
Lost works by creating **blocks**. Think of these blocks as columns in a traditional grid system, except they can go vertical as well. To create a basic horizontal grid, just insert some blocks into any element like so and pass a fraction (**as a string**) to `block()`.
4345

4446
```html
4547
<section>
@@ -64,7 +66,7 @@ You can also make use of the `center()` mixin to assign a `max-width` and `margi
6466

6567
```stylus
6668
section
67-
cf($max-size: 1200px, $pad: $gutter)
69+
center(980px)
6870
6971
figure
7072
block('1/2')
@@ -104,7 +106,7 @@ You can `offset` columns easily. To offset in the other direction, pass a negati
104106
```html
105107
<section>
106108
<figure>1</figure>
107-
<figure>3</figure>
109+
<figure>2</figure>
108110
</section>
109111
```
110112

@@ -169,33 +171,6 @@ for $i in 1..12
169171
block(s('%s/12', $i), $output: bare)
170172
```
171173

172-
```css
173-
[class*="col-"] {
174-
float: left;
175-
margin-right: 30px;
176-
}
177-
[class*="col-"]:last-child {
178-
margin-right: 0;
179-
}
180-
[class*="col-"]:nth-child(n) {
181-
clear: none;
182-
}
183-
[class*="col-"]:nth-child(1n + 1) {
184-
clear: both;
185-
}
186-
[class*="col-"]:nth-child(1n) {
187-
margin-right: 0;
188-
float: right;
189-
}
190-
.col-1 {
191-
width: calc(100% * 1/12 - (30px - 30px / 12));
192-
}
193-
.col-2 {
194-
width: calc(100% * 2/12 - (30px - 30px / 12));
195-
}
196-
...
197-
```
198-
199174
Once you've mastered the basic horizontal grid system (it shouldn't take long), you can start to make vertical grids that have the same vertical gutters as your horizontal grids. Just pass `$dir: column` to your `block()` mixin. The blocks will stretch to fill their container's height, so if you'd like to see them take up the full height of the page, set `height: 100%` on your container.
200175

201176
No other grid system in the world supports vertical grids.
@@ -247,7 +222,6 @@ Lost supports masonry plugins like [Isotope](http://isotope.metafizzy.co/). To a
247222
<figure>1</figure>
248223
<figure>2</figure>
249224
<figure>3</figure>
250-
...
251225
</section>
252226
```
253227

@@ -261,7 +235,8 @@ figure
261235

262236

263237
## Grid Settings
264-
Just set any of these in a settings file after you `@import` Lost and before you use a Lost mixin.
238+
239+
Just set either of these in a settings file after you `@import` Lost and before you use a Lost mixin.
265240

266241
- `$gutter = 30px`
267242
- `$rtl = false`
@@ -279,6 +254,7 @@ section
279254
edit(red)
280255
```
281256

257+
282258
##### `cf()`
283259
Clearfix used to clear floated children blocks. http://nicolasgallagher.com/micro-clearfix-hack
284260

@@ -289,6 +265,7 @@ Clearfix used to clear floated children blocks. http://nicolasgallagher.com/micr
289265
block('1/2')
290266
```
291267

268+
292269
##### `align()`
293270
Vertically and/or horizontally align nested elements.
294271

@@ -304,40 +281,29 @@ Vertically and/or horizontally align nested elements.
304281
height: 150px
305282
```
306283

284+
307285
##### `block()`
308286
Creates a block that is a fraction of the size of it's containing element with a gutter. Think of this like a column except it can go vertical as well by setting $dir to 'column' or 'both'. You don't need to pass any additional ratios (fractions) as the grid system will make use of calc(). Note that fractions must always be wrapped in quotes.
309287

310288
- `$fraction = '1/1'` - This is a simple fraction of the containing element's width or height depending on $dir. This must be a string written as a fraction.
311289
- `$dir = row` - The direction of the grid. Can be row (horizontal grid), column (vertical grid), or both (waffle grid).
312-
- `$cycle = 1` - Lost works by assigning a margin-right to all elements except the last in the row. It does this by default by using the denominator of the fraction you pick. To override this default use this param.
290+
- `$cycle = convert(unquote(split('/', $fraction)[1]))` (gets the denominator) - Lost works by assigning a margin-right to all elements except the last in the row. It does this by default by using the denominator of the fraction you pick. To override this default use this param. e.g. block('2/4', $cycle: 2)
313291
- `$gut = $gutter` - The margin on the side of the element used to create a gutter. Typically this is left alone and the global $gutter will be used, but you can override it here if you want certain elements to have a particularly large or small gutter (pass 0 for no gutter at all).
314-
- `$output = normal` - Determines what type of code to output. Accepts normal (all styles for a block), init (the initial styles of any block), or bare (just the width of the block). Useful for creating CSS grid classes like .col-x with Lost.
315292
- `$masonry-friendly = false` - Dictates whether this particular group of elements will work well with JS masonry plugins. This will assign a margin on each side of the element and you will need to wrap this group of elements in a masonry-row().
293+
- `$output = normal` - Determines what type of code to output. Accepts normal (all styles for a block), init (the initial styles of any block), or bare (just the width of the block). Useful for creating CSS grid classes like .col-x with Lost.
316294

317295
```stylus
318296
figure
319297
block('1/3')
320298
```
321299

322-
##### `masonry-row()`
323-
Creates a row element for working with JS masonry libraries like Isotope. Assigns a negative margin on each side of this wrapping element.
324-
325-
- `$gut = $gutter` - How large the gutter involved is, typically this won't be adjusted and will inherit the global $gutter setting, but it's made available if you want your masonry grid to have a special $gut, it should match your blocks' $guts.
326-
327-
```stylus
328-
section
329-
masonry-row()
330-
figure
331-
block('1/3', $masonry-friendly: true)
332-
```
333300

334301
##### `offset()`
335-
Margin to the left, right, bottom, or top, of an element depending on if the fraction passed is positive or negative. It works for both horizontal and vertical grids but not both. On vertical grids, the margin-top will create a gap on the bottom of the containing element the size of the margin-top. To get past this, apply overflow-y: hidden to your containing element.
302+
Margin to the left, right, bottom, or top, of an element depending on if the fraction passed is positive or negative. It works for both horizontal and vertical grids but not both.
336303

337304
- `$fraction = '1/1'` - Fraction of the container to be offset. Must be a string.
338305
- `$dir = row` - Direction the grid is going. Should match the block() it's being used on.
339306
- `$gut = $gutter` - How large the gutter involved is, typically this won't be adjusted, but if you have set the blocks for that row to have different gutters than default, you will need to match that gutter here as well.
340-
- `$masonry-friendly = false` - Determines whether this offset will work well with masonry friendly grids.
341307

342308
```stylus
343309
.two-elements
@@ -346,23 +312,35 @@ Margin to the left, right, bottom, or top, of an element depending on if the fra
346312
offset('1/3')
347313
```
348314

315+
349316
##### `move()`
350-
Source ordering. Shift elements left or right by their left position. Not very happy with this implementation: https://github.com/corysimmons/lost/issues/33
317+
Source ordering. Shift elements left, right, up, or down, by their left or top position by passing a positive or negative fraction.
351318

352319
- `$fraction = '1/1'` - Fraction of the container to be shifted. Must be a string.
353-
- `$spots = 1` - Number of spots to shift. So if you have 1/3 and shift it 2 spots to the right, it will end up on the 3/3 location. Can be negative. You might need to tweak these a bit for various sized objects.
354-
- `$cycle = 1` - If you have elements of unequal width, you can pass the number of items in the row to the $cycle param to help with the mathz involved.
320+
- `$dir = row` - Direction the grid is going. Should match the block() it's being used on.
355321
- `$gut = $gutter` - Adjust the size of the gutter for this movement. Should match the block's $gut.
356322
- `$output = normal` - Determines the type of output to produce. Accepts 3 options, normal (all the code), init (just the initialization code), and bare (just the left offset).
357323

358-
359324
```stylus
360325
figure
361326
block('1/3')
362327
move('1/3')
363328
```
364329

365330

331+
##### `masonry-row()`
332+
Creates a row element for working with JS masonry libraries like Isotope. Assigns a negative margin on each side of this wrapping element.
333+
334+
- `$gut = $gutter` - How large the gutter involved is, typically this won't be adjusted and will inherit the global $gutter setting, but it's made available if you want your masonry grid to have a special $gut, it should match your blocks' $guts.
335+
336+
```stylus
337+
section
338+
masonry-row()
339+
figure
340+
block('1/3', $masonry-friendly: true)
341+
```
342+
343+
366344
## Usage with Node
367345
- `npm i lost-grid --save-dev`
368346

@@ -392,9 +370,8 @@ figure
392370

393371

394372
## Browser Support
395-
- [`calc()` grids](https://webdesign.tutsplus.com/tutorials/calc-grids-are-the-best-grids--cms-22902) are IE9+ with poor support on old Android browsers ([`calc()` browser support](http://caniuse.com/#feat=calc)). With the [calc() Polyfill](https://github.com/closingtag/calc-polyfill) the grid works perfect in IE8 as well.
396-
- The vertical grids work perfect on IE9+ but even with polyfills elements are taller than they should be on IE8.
397-
- Nesting works perfect in IE9+ but breaks on IE8.
373+
- [`calc()` grids](https://webdesign.tutsplus.com/tutorials/calc-grids-are-the-best-grids--cms-22902) work perfect on IE9+ with poor support on old Android browsers ([`calc()` browser support](http://caniuse.com/#feat=calc)).
374+
- Currently awaiting this [Issue](https://github.com/closingtag/calc-polyfill/issues/10) to be fixed in order to support IE8 (with a polyfill obviously). If it's not fixed rather quickly, I will add support for IE8 manually.
398375

399376

400377
### Other Projects

0 commit comments

Comments
 (0)