/// Select all children from the first to `$num`. /// @param {Number} $num[] First `n` numbers of total children @mixin first($num) { @if $num == 1 { &:first-child { @content; } } @else { &:nth-child(-n + #{$num}) { @content; } } } /// Select the first exact child @mixin first-child { &:first-of-type { @content; } } /// Select all children from the last to `$num`. /// @param {Number} $num[] Last `n` numbers of total children @mixin last($num) { &:nth-last-child(-n + #{$num}) { @content; } } /// Select the last exact child @mixin last-child { &:last-of-type { @content; } } /// Select children every `$num`. /// @param {Number} $num[] Every `n` number of all children @mixin every($num) { &:nth-child(#{$num}n) { @content; } } /// Select only the first and last child. @mixin first-last { &:first-child, &:last-child { @content; } } /// Select all children after the first to `$num`. /// @param {Number} $num[] After First `n` numbers of total children @mixin after-first($num) { &:nth-child(n + #{$num + 1}) { @content; } } /// Select all children before `$num` from the last. /// @param {Number} $num[] From Last `n` numbers of total children @mixin from-last($num) { &:nth-last-child(#{$num}) { @content; } } /// Select the `$num` child from the first and the `$num` child from the last. /// @param {Number} $num[] `n` number called from first and last @mixin from-first-last($num) { &:nth-child(#{$num}), &:nth-last-child(#{$num}) { @content; } } /// Select all children but `$num`. /// @param {Number} $num[] `n` number that should be excluded from all other children @mixin all-but($num) { &:not(:nth-child(#{$num})) { @content; } } /// Select all children between the `$num` first and the `$num` last. /// @param {Number} $num[] `n` number excluded from first and last from all other children @mixin all-but-first-last($num) { &:nth-child(n + #{$num}):nth-last-child(n + #{$num}) { @content; } } /// Will only select the child if it’s unique. That means that if there are at least 2 children, the style will not be applied. @mixin unique { &:only-child { @content; } } /// Will only select children if they are not unique. That means that if there are at least 2 children, the style will be applied. @mixin not-unique() { &:not(:only-child) { @content; } } /// Select all children between `$first` and `$last`. /// @param {Number} $first[] First `nth` number /// @param {Number} $last[] Last `nth` number @mixin between($first, $last) { &:nth-child(n + #{$first}):nth-child(-n + #{$last}) { @content; } } /// Select all even children. @mixin even { &:nth-child(even) { @content; } } /// Select all even children between `$first` and `$last`. /// @param {Number} $first[] First `nth` number /// @param {Number} $last[] Last `nth` number @mixin even-between($first, $last) { &:nth-child(even):nth-child(n + #{$first}):nth-child(-n + #{$last}) { @content; } } /// Select all odd children. @mixin odd { &:nth-child(odd) { @content; } } /// Select all odd children between `$first` and `$last`. /// @param {Number} $first[] First `nth` number /// @param {Number} $last[] Last `nth` number @mixin odd-between($first, $last) { &:nth-child(odd):nth-child(n + #{$first}):nth-child(-n + #{$last}) { @content; } } /// Select all `$num` children between `$first` and `$last`. /// @param {Number} $num[] Every `n` number between `$first` and `$last`. /// @param {Number} $first[] First `n` number /// @param {Number} $last[] Last `n` number @mixin number-between($num, $first, $last) { &:nth-child(#{$num}n):nth-child(n + #{$first}):nth-child(-n + #{$last}) { @content; } }