SASS mixin for swapping images / floats on site language (change)
Posted
by
DBUK
on Stack Overflow
See other posts from Stack Overflow
or by DBUK
Published on 2012-10-25T16:46:13Z
Indexed on
2012/10/25
17:00 UTC
Read the original article
Hit count: 227
Currently using SASS on a website build. It is my first project using it, tried a little LESS before and liked it. I made a few basic mixins and variables with LESS, super useful stuff!
I am trying to get my head around SASS mixins, and syntax, specifically for swapping images when the page changes to a different language, be that with body ID changing or <html lang="en">
. And, swapping floats around if, for example, a website changed to chinese. So a mixin where float left is float left unless language is AR and then it becomes float right.
With LESS I think it would be something like:
.headerBg() when (@lang = en) {background-image:url(../img/hello.png);}
.headerBg() when (@lang = it) {background-image:url(../img/ciao.png);}
.header {.headerBg(); width: 200px; height:100px}
.floatleft() when (@lang = en) { float: left;}
.floatleft() when (@lang = ar) { float: right;}
.logo {.floatleft();}
Its the syntax I am having problems with combined with a brain melting day.
© Stack Overflow or respective owner