Skip to content

Instantly share code, notes, and snippets.

@Camwyn
Last active November 2, 2016 16:25
Show Gist options
  • Select an option

  • Save Camwyn/18676fe2fdfda64104e27226d021544e to your computer and use it in GitHub Desktop.

Select an option

Save Camwyn/18676fe2fdfda64104e27226d021544e to your computer and use it in GitHub Desktop.
Opacity mixins with fallback color
/**
* Translucent background colors with opaque text!
*
* @example scss
* @include background-opacity(#000, .5)
*
* @param {String} $color hexadecimal color
* @param {Integer} $opacity opacity value 0-1
*/
@mixin background-opacity( $color, $opacity: .5 ) {
background: $color; // fallback
background: rgba( $color, $opacity );
}
/**
* Translucent border colors
*
* @example scss
* @include background-opacity(#000, .5)
*
* @param {String} $color hexadecimal color
* @param {Integer} $opacity opacity value 0-1
*/
@mixin border-opacity( $color, $opacity: .5 ) {
border-color: $color; // fallback
border-color: rgba( $color, $opacity );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment