Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /// Select Last Half Of List
- /// $selector: what is the class or elemnt you would like to select
- /// $num: the max amout of items in list
- // Can be used on any elemnt you can add nth-child to
- // Keep in mind if $num is set to for example 10, it will not select the 11th items and beynad if they exist.
- @mixin last-half($selector, $num) {
- $count: 1;
- $return-value: ();
- $string: ();
- @while $count <= $num {
- @if $count == 1 {
- $string: '#{$selector}:first-child:last-child,';
- } @else {
- $string: '#{$selector}:nth-child(n+#{$count}):nth-last-child(-n+#{$count}),';
- }
- $return-value: append($return-value, $string);
- $count: $count + 1;
- }
- #{$return-value} {
- @content;
- }
- }
- /// Example
- //
- // ul {
- // ...
- // @include last-half('li', 10) {
- // ...
- // }
- // }
Add Comment
Please, Sign In to add comment