Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

CSS Advanced Sass Advanced Directives Defining Breakpoints with @content

Zeljko Porobija
Zeljko Porobija
11,490 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,490 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,490 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;
  }
}```