Pergunta

wondering how to make the . outside of the $value

@mixin opacity($value) {
    opacity: .$value;
}

How escape that dot .? I want this:

.foo {
    @include opacity(3);
}

To generate this:

.foo {
    opacity: .3;
}
Foi útil?

Solução

The correct way to do this is to use division. Using string interpolation just gives you a string, which is unsuitable for passing to Sass functions that expect numbers:

@mixin opacity($value) {
    opacity: $value / 10;
}

.foo {
    background-color: rgba(5, 5, 5, $value / 10);
}

Outras dicas

Just like this:

@mixin opacity($value){
  opacity: unquote('.#{$value}');
}
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top