I like to make mixins with SASS that help me make good cross-browser compatibility. I want to make a mixin that looks like this:
@mixin box-shadow($value) {
box-shadow: $value;
-webkit-box-shadow: $value;
-moz-box-shadow: $value;
}
to which I can pass something like this:
@include box-shadow(inset -2px -2px 2px rgba(0,0,0,0.5), inset 1px 1px 2px rgba(255,255,255,0.5), inset 0px 0px 0px 1px #ff800f);
with the result being something like this:
box-shadow: inset -2px -2px 2px rgba(0,0,0,0.5), inset 1px 1px 2px rgba(255,255,255,0.5),inset 0px 0px 0px 1px #ff800f;
-moz-box-shadow: inset -2px -2px 2px rgba(0,0,0,0.5), inset 1px 1px 2px rgba(255,255,255,0.5),inset 0px 0px 0px 1px #ff800f;
-webkit-box-shadow: inset -2px -2px 2px rgba(0,0,0,0.5), inset 1px 1px 2px rgba(255,255,255,0.5),inset 0px 0px 0px 1px #ff800f;
However, This doesn't work because the complier thinks I am trying to pass the mixin 3 arguments. box-shadow takes a variable number of comma separated bits, so I can't just define a mixin like box-shadow($1,$2,$3).
I tried passing
@include box-shadow("inset -2px -2px 2px rgba(0,0,0,0.5), inset 1px 1px 2px rgba(255,255,255,0.5), inset 0px 0px 0px 1px #ff800f");
and it compiled, but didn't actually render the styles.
Any tips on how to resolve this?
rgbamostly for others starting to use Sass (since I know everyone else here already knows this :]). Instead of having to typergba(0,0,0,0.5);you can typergba(black,.5). Same goes withwhite,red, etc. and all other CSS colors, that way you don't have to type the actual RGB value itself. You can also use hex values:rgba(#258,.5);. Or color variables:rgba($colorVariable,.5). Hope that helps. - Ricardo Zea