Search code examples
sasscompass-sass

How to add !important to @include opacity(1) in compass


I am using compass. Is there any way to add !important to @include opacity(1)?

Thanks!


Solution

  • Yes. You can use @if and @else

    =opacity($opacity, $important: no)
        @if $important == isImportant
            opacity: $opacity !important
            $opacity-ie: $opacity * 100
            filter: alpha(opacity=$opacity-ie) !important //IE8
        @else
            opacity: $opacity
            $opacity-ie: $opacity * 100
            filter: alpha(opacity=$opacity-ie) //IE8
    
    
    .some-class
        +opacity(1) // without !important
    
    .some-class
        +opacity(1, isImportant) // with !important
    

    if it is what u ment