Created
November 30, 2011 10:25
-
-
Save calvincorreli/1408585 to your computer and use it in GitHub Desktop.
IE gradient mixin with SCSS/SASS
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
@mixin gradient($first, $second) { | |
background-color: $second; | |
-ms-filter: "progid:DXImageTransform.Microsoft.gradient(GradientType=0, startColorstr='#{ie-hex-str($first)}', endColorstr='#{ie-hex-str($second)}');"; | |
filter: progid:DXImageTransform.Microsoft.gradient(GradientType=0, startColorstr='#{ie-hex-str($first)}', endColorstr='#{ie-hex-str($second)}');; | |
zoom: 1; | |
background: -webkit-gradient(linear, left top, left bottom, from($first), to($second)); | |
background: -moz-linear-gradient(top, $first, $second); | |
} |
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
require 'sass' | |
module Sass::Script::Functions | |
# LARS: Snatched from compass - 2011-11-29 - used for gradients in IE6-9 | |
# returns an IE hex string for a color with an alpha channel | |
# suitable for passing to IE filters. | |
def ie_hex_str(color) | |
assert_type color, :Color | |
alpha = (color.alpha * 255).round | |
alphastr = alpha.to_s(16).rjust(2, '0') | |
Sass::Script::String.new("##{alphastr}#{color.send(:hex_str)[1..-1]}".upcase) | |
end | |
declare :ie_hex_str, [:color] | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Answering my own question: I need to "@import" the mixin scss file in active_admin.css.scss
BTW setting "alphastr" to "00" works better for activeadmin buttons (the default is "FF", displaying a white background for rounded buttons).