3

I want to write this mixin:

@mixin top_a($sep-a: 2.5) {
padding-top: $sep-a + %;}

But unfortunately this throws in an error. How do I add the percentage to the value correctly?

KSPR
  • 2,212
  • 4
  • 29
  • 46
  • It looks like you want a variable, not a mixin – Matt Whipple Oct 21 '12 at 12:29
  • Interesting. I can get it to work with `px` as `#{$sep-a}px`, but if I replace `px` by `%` sass chokes. – Thomas Oct 21 '12 at 12:43
  • @Thomas - it's not a good idea because `#{$sep-a}px` return string and `$sep-a * 1px` return value. Here you have [example](http://stackoverflow.com/q/8254941/1017941) of this error. – Hauleth Oct 23 '12 at 22:12

1 Answers1

4

Why not simply multiply by 1%?

padding-top: $sep-a * 1%;
Hauleth
  • 22,873
  • 4
  • 61
  • 112