문제

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