Skip to content

Instantly share code, notes, and snippets.

@kokarn
Created December 11, 2014 13:53
Show Gist options
  • Save kokarn/243fd0acbb89045f657a to your computer and use it in GitHub Desktop.
Save kokarn/243fd0acbb89045f657a to your computer and use it in GitHub Desktop.
LESS mixin for using nth-child on IE7 & IE8
.clear-nth( @selector, @n, @currentSelector: '', @i: 1 ) when ( mod( @i, @n + 1 ) = 0 ) and ( @i < 100 ){
@updatedSelector: e( '@{currentSelector} + @{selector}' );
@{updatedSelector} {
clear: both;
}
.clear-nth( @selector, @n, @updatedSelector, ( @i + 1 ) );
}
.clear-nth( @selector, @n, @currentSelector: '', @i: 1 ) when not ( mod( @i, @n + 1 ) = 0 ) and ( @i < 100 ) and not( @i = 1 ){
@updatedSelector: e( '@{currentSelector} + @{selector}' );
.clear-nth( @selector, @n, @updatedSelector, ( @i + 1 ) );
}
.clear-nth( @selector, @n, @currentSelector: '', @i: 1 ) when not ( mod( @i, @n + 1 ) = 0 ) and ( @i < 100 ) and ( @i = 1 ){
@updatedSelector: e( '@{selector}:first-child' );
.clear-nth( @selector, @n, @updatedSelector, ( @i + 1 ) );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment