Skip to Content
Menu

background-color()

Apply a cross-browser friendly background color with optional alpha opacity.

Sass February 22, 2017

Usage

Sass
background-color($color, $opacity)

Parameters

$color
(Required) (String) The background color
Default: None

$opacity
(Optional) (Integer) Alpha (between 0-1)
Default: 1

Request or provide clarification »

Examples

Sass
.element {@include background-color(#333, 0.5);}
Was this page helpful? Yes No


    A feedback message is required to submit this form.


    Please check that you have entered a valid email address.

    Enter your email address if you would like a response.

    Thank you for your feedback!

    Source File

    Located in /assets/scss/partials/_mixins.scss on line 135.

    Sass
    @mixin background-color($color, $opacity: 10%){
        background-color: $color; background-color: rgb($color, $opacity);
    }
    

    Override

    To override or disable this, redefine the mixin/function later on, or use different class names to prevent this from targeting your element.

    Sass
    @mixin background-color($color, $opacity){
        //Write your own code here, leave it blank, or return false.
    }