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

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

Thanks!

+4
source share
3 answers

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 that's what it means

+5
source

This is the same code in the 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 
+2
source

A little late, but it might be useful for someone out there. You can simply specify !important as part of the property value:

 @include opacity(1 !important); 

This may not work in all cases, depending on the structure of your mixin, but in most cases it should be.

0
source

Source: https://habr.com/ru/post/1485950/


All Articles