Hi all I'm new to SASS (late I know) and playing around with mixins.
Basically is there a way to link a variable to a string here is what I'm trying to do but it throws errors. (This is a condensed version)
@mixin post-link ($class, $color, $hover) { a.$class:link { color: $color; } a.$class:hover { color: $hover; } }
Link I say this is a little simpler than what I am trying to do in the mixin (more variables in full one).
EDIT: should add i'm using Compass. Thanks
Yes, you just have to use variable interpolation. Example:
@mixin post-link ($class, $color, $hover) { a.#{$class}:link { color: $color; } a.#{$class}:hover { color: $hover; } }
Example on SassMeister: http://sassmeister.com/gist/9533103
The key is adding #{
and }
around your variable names to get them expanded.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With