Вопрос

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;
}
Это было полезно?

Решение

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);
}

Другие советы

Just like this:

@mixin opacity($value){
  opacity: unquote('.#{$value}');
}
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top