Skip to content
Snugug edited this page Jun 9, 2013 · 4 revisions

Breakpoint now includes the alternative Respond-to syntax which provides for slightly more semantic reading of your media queries when used. There's nothing additional you need to import, and it supports all of the features of standard Breakpoint. Usage is simple; using the $breakpoints variable, set a string name and associated breakpoint query, and then call respond-to instead of breakpoint.

// We can use all of the Breakpoint control variables with respond-to as well!
$breakpoint-no-query-fallbacks: true;
$breakpoint-to-ems: true;

// These numbers were chosen at random. Don't look too far into them.
$breakpoints: 'one column to two columns' 456px,
              'between medium and large' (876px 1324px, 'no-query' '.no-mq'),
              'high resolution' (min-resolution 1.5dppx),
              'handheld device or landscape' (handheld, orientation landscape),
              'coarse input' (pointer coarse);

#foo {
  @include respond-to('one column to two columns') {
    // We can, of course, use breakpoint-get-context as well with respond-to
    content: "min-width:" breakpoint-get-context('min-width');
  }
  @include respond-to('between medium and large') {
    content: 'This is between a medium and large size';
  }
  @include respond-to('high resolution') {
    content: 'This has a fairly high resolution';
  }
  @include respond-to('handheld device or landscape') {
    content: "Handheld device, or maybe it's in landscape";
  }
  @include respond-to('coarse input', $no-query: '.touch') {
    content: 'Coarse input method';
  }
}
@media (min-width: 28.5em) {
  #foo {
    content: "min-width:" 456px;
  }
}
@media (min-width: 54.75em) and (max-width: 82.75em) {
  #foo {
    content: 'This is between a medium and large size';
  }
}
.no-mq #foo {
  content: 'This is between a medium and large size';
}
@media (min-resolution: 1.5dppx), (-webkit-min-device-pixel-ratio: 1.5), (min--moz-device-pixel-ratio: 1.5), (min-resolution: 144dpi) {
  #foo {
    content: 'This has a fairly high resolution';
  }
}
@media handheld, (orientation: landscape) {
  #foo {
    content: "Handheld device, or maybe it's in landscape";
  }
}
@media (pointer: coarse) {
  #foo {
    content: 'Coarse input method';
  }
}
.touch #foo {
  content: 'Coarse input method';
}