Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

CSS Sass Basics Add Reusable Logic to Your Sass Add Conditional Logic to Your Stylesheets

Jared Ledbetter
Jared Ledbetter
21,672 Points

@else not working correctly

I followed the details exactly, and even used my text editor to validate the code. Still not working in the workspace. Don't know how to fix it.

// Create Media Queries

@mixin mq($break) {
  @if $break == 'xs' {
    @media (max-width: $break-xs) {
      @content;
    }
    @else if $break == 'sm'  {
      @media (min-width: $break-s) {
        @content;
      }    
    }
    @else if $break == 'med'  {
      @media (min-width: $break-m) {
        @content;
      }    
    }
    @else if $break == 'lg'  {
      @media (min-width: $break-l) {
        @content;
      }    
    }    
  }
}
Cheo R
Cheo R
37,150 Points

Looks like your else if conditions are nested in the first if.

Jared Ledbetter
Jared Ledbetter
21,672 Points

Cheo R, Thanks for the catch. Now I've got a new error.

error scss/utilities/_mixins.scss (Line 57: Invalid null operation: "null lt null".)

// Create Media Queries

@mixin mq($break) {
  $value: map-get($breakpoints, $break);
  $sm: map-get($breakpoints, 'sm');

  @if $value < $sm {                           // LINE 57 IS HERE
    @media (max-width: $value) {
      @content;
    }
  }
  @else {
    @media (min-width: $value) {
      @content;
    }
  }
}

1 Answer

Jared Ledbetter
Jared Ledbetter
21,672 Points

SOLVED:

The problem was that my breakpoints in the variables were still showing the old values.

SHOWING WRONG:

// Breakpoints
$breakpoints:(
  'xs': 575px,  
  's': 576px,
  'm': 768px,
  'l': 992px,
);

FIXED:

// Breakpoints
$breakpoints:(
  'xs': 575px,  
  'sm': 576px,
  'med': 768px,
  'lg': 992px,
);