I am using compass. Is there any way to add !important to @include opacity(1)?
Thanks!
I am using compass. Is there any way to add !important to @include opacity(1)?
Thanks!
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
This is the same code in SCSS syntax, maybe someone can use it:
@mixin opacity($opacity, $important: 0) {
@if $important == 1 {
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
@include opacity(1); // without !important
.some-class
@include opacity(1,1); // with !important
A bit late, but this might be useful to someone out there. You could simply specify !important
as part of the property value:
@include opacity(1 !important);
It might not work in every case depending on your mixin structure, but in most cases it should.