Created
May 28, 2014 07:51
-
-
Save maddesigns/af1d02e3217789ed7567 to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="list-item">1</div> | |
<div class="list-item">2</div> | |
<div class="list-item">3</div> | |
<div class="list-item">4</div> | |
<div class="list-item">5</div> | |
<div class="list-item">6</div> | |
<div class="list-item">7</div> | |
<div class="list-item">8</div> | |
<div class="list-item">9</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ---- | |
// Sass (v3.3.7) | |
// Compass (v1.0.0.alpha.18) | |
// ---- | |
@function strip-units($number) { | |
@return $number / ($number * 0 + 1); | |
} | |
@mixin nth-child($an: 2n, $sibling: "*", $count: 15) { | |
$index: ""; | |
$n: false; | |
$selector: ""; | |
$modifier: 0; | |
@if type-of($an) == list { | |
$index: nth($an, 1); | |
$modifier: nth($an, 2); | |
} | |
@else { | |
$index: $an; | |
} | |
@if $index == "even" or $index == even { | |
$index: 2n; | |
} | |
@if $index == "odd" or $index == odd { | |
$index: 2n; | |
$modifier: 1; | |
} | |
@if unit($index) == "n" { | |
$index: strip-units($index); | |
$n: true; | |
} | |
@if $modifier < 0 { | |
@if abs($modifier) > $index { | |
$modifier: -(abs($modifier) % floor($index)); | |
} | |
$modifier: $modifier + floor($index); | |
} | |
@if $index > 0 { | |
@if $n == false { | |
$count: 1; | |
} | |
@if $index == 1 { | |
$selector: "&:first-child"; | |
} | |
@if $modifier > 1 { | |
@for $j from 0 to $modifier - 1 { | |
$selector: $selector + "+ " + $sibling; | |
} | |
$selector: $selector + ","; | |
} | |
@for $i from 1 to $count + 1 { | |
@if $i > 1 { | |
$selector: $selector + ", "; | |
} | |
@for $x from 1 - $modifier to $index * $i { | |
$selector: $selector + "+ " + $sibling; | |
} | |
} | |
} | |
@if $index > 0 { | |
@if $modifier == 1 { | |
@content; | |
} | |
#{$selector} { | |
@content; | |
} | |
} | |
} | |
.list-item { | |
width: 32.33334%; | |
margin-right: 1%; | |
float: left; | |
clear: none; | |
box-shadow: inset 0 0 1px red; | |
} | |
.list-item { | |
@include nth-child($an: 3n, $sibling: "div", $count: 3) { | |
margin-right: 0; | |
} | |
@include nth-child($an: 4n, $sibling: "div", $count: 3) { | |
clear: left; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.list-item { | |
width: 32.33334%; | |
margin-right: 1%; | |
float: left; | |
clear: none; | |
box-shadow: inset 0 0 1px red; | |
} | |
.list-item + div + div, .list-item + div + div + div + div + div, .list-item + div + div + div + div + div + div + div + div { | |
margin-right: 0; | |
} | |
.list-item + div + div + div, .list-item + div + div + div + div + div + div + div, .list-item + div + div + div + div + div + div + div + div + div + div + div { | |
clear: left; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="list-item">1</div> | |
<div class="list-item">2</div> | |
<div class="list-item">3</div> | |
<div class="list-item">4</div> | |
<div class="list-item">5</div> | |
<div class="list-item">6</div> | |
<div class="list-item">7</div> | |
<div class="list-item">8</div> | |
<div class="list-item">9</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment