SASS function does not work

0

Good morning! I'm doing some testing with the sass function it does not return anything to me. I figured it was something I was typing wrong, or something. I have copied the exact function of this site here and still the error continues. The function is here

        @function cp($target, $container) {
      @return calc-percent($target, $container);
    }
.my-module {
  width: calc-percent(650px, 1000px);
}

I have already cleaned the browser cache, I have already tried on online tools ... Anyway, what could I do?

    
asked by anonymous 04.09.2014 / 15:54

2 answers

1

You did not call the function. I believe the correct one would be:

.my-module {
   width: cp(650px, 1000px);
}
    
04.09.2014 / 15:56
0

The link you entered in the question shows two functions. One is the calc-percent and the other is the cp which is just a minor name for the function already declared.

@function calc-percent($target, $container) {
  @return ($target / $container) * 100%;
}

@function cp($target, $container) {
  @return calc-percent($target, $container);
}

.my-module {
  width: cp(650px, 1000px);
}

It works perfectly, possibly you have not declared the calc-percent function. By abstracting it it gets even simpler the code.

@function cp($target, $container) {
  @return ($target / $container) * 100%;
}

.my-module {
  width: cp(650px, 1000px);
}

That results in the following CSS:

.my-module {
  width: 65%;
}
    
28.01.2016 / 16:14