Skip to content

Instantly share code, notes, and snippets.

@unisys12
Created March 1, 2014 20:28
Show Gist options
  • Save unisys12/78badd4b30a2993b8588 to your computer and use it in GitHub Desktop.
Save unisys12/78badd4b30a2993b8588 to your computer and use it in GitHub Desktop.
##SVG_Colorizer RGBA This version is the same as before, but supports RGBA... of course.
@mixin svg_colorize($red, $green, $blue, $alpha) {
fill: rgba($red, $green, $blue, $alpha);
&:hover {
fill: rgba($red, $green, $blue, $alpha - .2);
}
}
/*****************
* Useage Example*
****************/
// In your HTML, just place your inline SVG as needed
<li>
<a href="mailto:[email protected]" class="mail">
<svg version="1.1" width="32" height="32" viewBox="0 0 32 32">
<path d="M16 0c-8.837 0-16 7.163-16 16s7.163 16 16 16 16-7.163 16-16-7.163-16-16-16zM8 8h16c0.286 0 0.563 0.061 0.817 0.177l-8.817 10.286-8.817-10.287c0.254-0.116 0.531-0.177 0.817-0.177zM6 22v-12c0-0.042 0.002-0.084 0.004-0.125l5.864 6.842-5.8 5.8c-0.045-0.167-0.069-0.34-0.069-0.517zM24 24h-16c-0.177 0-0.35-0.024-0.517-0.069l5.691-5.691 2.826 3.297 2.826-3.297 5.691 5.691c-0.167 0.045-0.34 0.069-0.517 0.069zM26 22c0 0.177-0.024 0.35-0.069 0.517l-5.8-5.8 5.865-6.842c0.003 0.041 0.004 0.083 0.004 0.125v12z" fill="#222222" class="svg_mail" />
</svg>
</a>
</li>
// Then, in your scss just use it as follows
.svg_mail {
@include svg_colorize(2, 80, 214, 1);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment