Skip to content

Instantly share code, notes, and snippets.

@imathis
Created July 16, 2009 19:50
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save imathis/148655 to your computer and use it in GitHub Desktop.
Save imathis/148655 to your computer and use it in GitHub Desktop.
Use this SASS mixin to assign cross-browser CSS opacity
// expects a number from 0 to 100
=opacity(!opacity, !hover_opacity = false)
:opacity= !opacity / 100
:-moz-opacity= !opacity / 100
:-ms-filter= "progid:DXImageTransform.Microsoft.Alpha(Opacity=#{!opacity})"
:filter= "alpha(opacity=#{!opacity})"
@if !hover_opacity
+opacity-hover(!hover_opacity)
=opacity-hover(!opacity)
&:hover
+opacity(!opacity)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment