Skip to content

Instantly share code, notes, and snippets.

@PhilippeVay
Last active August 29, 2015 13:55
Show Gist options
  • Save PhilippeVay/8755112 to your computer and use it in GitHub Desktop.
Save PhilippeVay/8755112 to your computer and use it in GitHub Desktop.
LESS: parent selector '&' combined with 'if' when()
/* &:focus, &:hover, &:active isn't the only way of using the parent selector in LESS */
@rtl_option: true;
ul, ol {
padding-left: 2em;
/* RTL */
[dir="rtl"] & when (@rtl_option) {
padding-left: 0;
padding-right: 2em;
}
}
/*
Should output:
ul, ol {
padding-left: 2em;
}
/* RTL */
[dir="rtl"] ul,
[dir="rtl"] ol {
padding-left: 0;
padding-right: 2em;
}
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment