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 Advanced Sass Advanced Directives Defining Breakpoints with @content

Zeljko Porobija
Zeljko Porobija
11,491 Points

I do not get the same results

My scss code is the same as the tutorial's, but the output differs. Here's my scss file:

Zeljko Porobija
Zeljko Porobija
11,491 Points
directive.scss
$font-size: 12;

@function em($target, $context: $font-size) {
  @return ($target / $context) * 1em;
}

$break-small: em(320);
$break-large: em(1200);

@mixin respond-to($media) {
  @if $media == handhelds {
    @media only screen and (max-width: $break-small) {@content;}
  }
  @else if $media == medium-sreens {
    @media only screen and (min-width: $break-small + 1) and (max-width: $break-large - 1) {@content;}
  }
  @else if $media == wide-sreens {
    @media only screen and (min-width: $break-large) {@content;}
  }
}

.profile-pic {
  float: left;
  width: em(250);
  @include respond-to(handhelds) {
    width: em(100);
    float: none;
  }
  @include respond-to(medium-screens) {
    width: em(125);
  }
  @include respond-to(wide-screens) {
    float: right;
  }
} ```

2 Answers

try this

$font-size: 12;

@function em($target, $context: $font-size){
  @return ($target / $context) * 1em;
}

$break-small: em(320);
$break-large: em(1220);

@mixin respond-to($media){
  @if $media ==  handhelds {
    @media only screen and (max-width:$break-small) {@content;}
  }
  @else if $media == media-screens {
    @media only screen and (min-width:$break-small + 1) and (max-width: $break-large - 1) { @content;}
  }
  @else if $media == wide-screens {
    @media only screen and (min-width: $break-large) {@content;}
  }
}

.profile-pic{
  float:left;
  width:em(250);
  @include respond-to(handhelds){
    width:em(100);
    float:none;
  }
  @include respond-to(media-screens){
    width:em(125);
  }
  @include respond-to(wide-screens){
    float:right;
  }
}
Zeljko Porobija
Zeljko Porobija
11,491 Points
directive.css
.profile-pic {
  float: left;
  width: 20.83333em;
}
@media only screen and (max-width: 26.66667em) {
  .profile-pic {
    width: 8.33333em;
    float: none;
  }
}```