-
-
Save overcome/a8be24af2470083531e7152af8e70642 to your computer and use it in GitHub Desktop.
CSS3 Filter Effects Sass Mixin
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://dvcs.w3.org/hg/FXTF/raw-file/tip/filters/index.html | |
// | |
// grayscale ex: filter: grayscale(100%); | |
// sepia ex: filter: sepia(100%); | |
// saturate ex: filter: saturate(0%); | |
// hue-rotate ex: filter: hue-rotate(45deg); | |
// invert ex: filter: invert(100%); | |
// brightness ex: filter: brightness(15%); | |
// contrast ex: filter: contrast(200%); | |
// blur ex: filter: blur(2px); | |
=filter($filter-type,$filter-amount) | |
-webkit-filter: $filter-type+unquote('(#{$filter-amount})') | |
-moz-filter: $filter-type+unquote('(#{$filter-amount})') | |
-ms-filter: $filter-type+unquote('(#{$filter-amount})') | |
-o-filter: $filter-type+unquote('(#{$filter-amount})') | |
filter: $filter-type+unquote('(#{$filter-amount})') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://dvcs.w3.org/hg/FXTF/raw-file/tip/filters/index.html | |
// | |
// grayscale ex: filter: grayscale(100%); | |
// sepia ex: filter: sepia(100%); | |
// saturate ex: filter: saturate(0%); | |
// hue-rotate ex: filter: hue-rotate(45deg); | |
// invert ex: filter: invert(100%); | |
// brightness ex: filter: brightness(15%); | |
// contrast ex: filter: contrast(200%); | |
// blur ex: filter: blur(2px); | |
@mixin filter($filter-type,$filter-amount) { | |
-webkit-filter: $filter-type+unquote('(#{$filter-amount})'); | |
-moz-filter: $filter-type+unquote('(#{$filter-amount})'); | |
-ms-filter: $filter-type+unquote('(#{$filter-amount})'); | |
-o-filter: $filter-type+unquote('(#{$filter-amount})'); | |
filter: $filter-type+unquote('(#{$filter-amount})'); | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
img { | |
-webkit-filter: grayscale(100%); | |
-moz-filter: greyacale(100%); | |
-ms-filter: grayscale(100%); | |
-o-filter: grayscale(100%); | |
filter: grayscale(100%); } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
img | |
+filter(grayscale,100%) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
img { | |
@include filter(grayscale, 100%); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment