d-cmst
d-cmst

Reputation: 474

sass load mixin conditionally based on media query

Is it possibile to load/unload mixins based on a media query? Something like this:

@if @media (min-width: 768px) {
    @include mixin1;
}
@else {
    @include mixin2;
}

if the condition is met, mixin2 should not be loaded at all.

Upvotes: 0

Views: 102

Answers (1)

sleukeleire
sleukeleire

Reputation: 136

Not really, the sass compiles server side, not knowing the clients screen size. The compiled css will be used for all screen widths, thus:

@include mixin2;
@media (min-width: 768px) {
  @include mixin1;
}

Upvotes: 2

Related Questions