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 |
Author
calvincorreli
commented
May 4, 2012
via email
config/initializers/sass_helpers.rb is where mine lives
##
http://consciousstartups.com - a conscious approach to entrepreneurship
http://zenbilling.com - software for online teaching
Twitter: @calvinconaway
Other contact info:
http://pinds.com/contact
…On Friday, May 4, 2012 at 10:59 PM, Dustin Secrest wrote:
Where would one put this sass_helpers.rb file in a rails project?
---
Reply to this email directly or view it on GitHub:
https://gist.github.com/1408585
Where to put the mixins.css.scss file? I put it to *lib/assets/stylesheets/" but it doesn't work, seems not overriding activeadmin's default gradient mixin.
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).
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment