Skip to content

Instantly share code, notes, and snippets.

@tsmith512
Last active August 29, 2015 14:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tsmith512/3c044df6fb5602d0eb18 to your computer and use it in GitHub Desktop.
Save tsmith512/3c044df6fb5602d0eb18 to your computer and use it in GitHub Desktop.
Proposal for a better rtl() mixin that takes a class name
// ----
// Sass (v3.4.12)
// Compass (v1.0.3)
// ----
@mixin rtl($class: '') {
#{'html[dir="rtl"]' + $class} & {
@content;
}
}
.view {
text-align: left;
@include rtl {
text-align: right;
}
}
.fanciness {
html.flexbox & {
color: red;
}
@include rtl('.flexbox') {
color: blue;
}
}
.view {
text-align: left;
}
html[dir="rtl"] .view {
text-align: right;
}
html.flexbox .fanciness {
color: red;
}
html[dir="rtl"].flexbox .fanciness {
color: blue;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment