Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SASS/SCSS change variable value before extend

Tags:

sass

I have Bootstrap 3.3.7 and custom scss files.

I want to override $grid-float-breakpoint only once before @extend evaluates. Right now I have 3 classes which extend base bootstrap class (they use default value, so i don't want to mess with them).

In doc when using mixins and include it's possible. Is it possible using .class and @extend?

I'm looking for something like

    $foo : 1px;

    .normal-class {
      font-size: $foo;
    }

    .extended-normal-class {
      @extend .normal-class;
      font-color: yellow;
    }

    -- This is what I'm trying to do: ---------------------
    .override-class {
      $foo: 3px;
      @extend .normal-class; 
     // font-size in this class after compile should have 3px;
    }
like image 922
Mike Quoro Avatar asked Jan 22 '26 18:01

Mike Quoro


1 Answers

To achiev what you need, you must use @mixin instead of @extend, heres follow an example:

@mixin size($size: 1px){
   font-size: $size;
}

.extended-normal-class{
   @include size();
}

.override-class{
   @include size(3px);
}
like image 187
João Deroldo Avatar answered Jan 25 '26 10:01

João Deroldo