0

I tried to use Less mixin but its not working because I'm passing multiple linear values:

.MultiStepGradient(@multigrad) {
    background-image: -moz-linear-gradient(@multigrad);
    background-image: -webkit-linear-gradient(@multigrad);
    background-image: -o-linear-gradient(@multigrad);
    background-image: -ms-linear-gradient(@multigrad);
    background-image: linear-gradient(@multigrad);
}

.test {
    .MultiStepGradient(135deg,#202f7c 0%, #7f3689 52%, #7f3689 100%);
}

Error: No matching definition was found for .MultiStepGradient(135deg, #202f7c 0%, #7f3689 52%, #7f3689 100%)

seven-phases-max
  • 11,765
  • 1
  • 45
  • 57
jinfy
  • 147
  • 1
  • 12
  • escape the value or pass multiple values – Huangism Feb 21 '18 at 15:13
  • Possible duplicate of [escape whole declaration in less css](https://stackoverflow.com/questions/8289883/escape-whole-declaration-in-less-css) – Huangism Feb 21 '18 at 15:16
  • See [Mixins with Multiple Parameters](http://lesscss.org/features/#mixins-feature-mixins-with-multiple-parameters). – seven-phases-max Feb 21 '18 at 18:34
  • Duplicate of [How do you create multiple box-shadow values in LESS CSS](https://stackoverflow.com/questions/9231369/how-do-you-create-multiple-box-shadow-values-in-less-css) – seven-phases-max Feb 21 '18 at 18:40

1 Answers1

-1

Pass it like this, escaping it

.MultiStepGradient(~"135deg,#202f7c 0%, #7f3689 52%, #7f3689 100%")

you could change the mixin to take multiple values if you want to pass it the way you are doing it now

http://lesscss.org/functions/#string-functions-escape

Scroll down a little to see the e section

CSS escaping, replaced with ~"value" syntax.

It expects string as a parameter and return its content as is, but without quotes. It can be used to output CSS value which is either not valid CSS syntax, or uses proprietary syntax which Less doesn't recognize.

Huangism
  • 16,278
  • 7
  • 48
  • 74
  • I could guess yourself (a. answering a clear duplicate b. see answers in linked tickets above). – seven-phases-max Feb 22 '18 at 09:49
  • And yes (I amost forgot) - for use-cases like this dicover the autoprefixing tools and forget about writing such mixins *forever*. – seven-phases-max Feb 22 '18 at 10:37
  • Always good to provide an answer because you never know if the question will get closed or not, besides I already voted to close as I put the answer down. This has nothing to do with prefixes, it's a case of not knowing how to escape parameters – Huangism Feb 22 '18 at 14:01
  • *Always good to provide an answer* - no, because these modern "smart" searching engines (not just built-in SO query) may prefer older answered question to an newer unanswered one, so by answering you just push potentially better Q/As down (and introduce extra noise for others who will search for similar thing and/or its duplicates later). – seven-phases-max Feb 22 '18 at 16:44
  • Yea that's a possibility but it's also possible when someone stumbles upon this question and seeing no answer then leaving the page without reading comments or the duplicated question(someone who doesn't use SO) – Huangism Feb 22 '18 at 17:31