Guest User

Untitled

a guest
Jan 21st, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. /// Select Last Half Of List
  2. /// $selector: what is the class or elemnt you would like to select
  3. /// $num: the max amout of items in list
  4.  
  5. // Can be used on any elemnt you can add nth-child to
  6.  
  7. // Keep in mind if $num is set to for example 10, it will not select the 11th items and beynad if they exist.
  8.  
  9. @mixin last-half($selector, $num) {
  10. $count: 1;
  11. $return-value: ();
  12. $string: ();
  13.  
  14. @while $count <= $num {
  15.  
  16. @if $count == 1 {
  17. $string: '#{$selector}:first-child:last-child,';
  18. } @else {
  19. $string: '#{$selector}:nth-child(n+#{$count}):nth-last-child(-n+#{$count}),';
  20. }
  21.  
  22. $return-value: append($return-value, $string);
  23. $count: $count + 1;
  24. }
  25.  
  26. #{$return-value} {
  27. @content;
  28. }
  29. }
  30.  
  31.  
  32. /// Example
  33. //
  34. // ul {
  35. // ...
  36. // @include last-half('li', 10) {
  37. // ...
  38. // }
  39. // }
Add Comment
Please, Sign In to add comment