cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

Quick-add: + add another resource

Code Indentation

     

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

            
              <section>
    <h1>Sass Breakpoint Mixin Demo</h1>
    <p class="breaking-mobile">Mobile First</p>
    <p class="breaking-medium">Medium Value</p>
    <p class="breaking-large">Large Value</p>

    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Sunt cum accusamus ullam facilis corporis natus omnis vero illo voluptas error impedit quo perferendis rerum. Voluptatibus molestias deserunt quod modi delectus sit incidunt qui facere quaerat quae molestiae veniam non numquam!</p>

    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Veniam nam voluptatibus aperiam dolore odio modi expedita dolor recusandae quas id.</p>
</section>
            
          
!
            
              @import "compass/css3";

// Sass Breakpoint Mixin
@mixin breakpoint($point) {
    @if $point == medium {
        @media (min-width: 30em)  { @content; }
    }
    @else if $point == large {
        @media (min-width: 50em) { @content; }
    }
    @else if $point { // allows custom breakpoints
        @media (min-width: $point) { @content; }
    }
}


// demo styling & examples
body {
    background: #517293;
    font-size: 100%;
    line-height: 1.6;
    color: #f1f1f1;

    @include breakpoint(medium) {
        background: darken(#517293, 7.5%);
        font-size: 120%;
    }
    @include breakpoint(large) {
        background: darken(#517293, 15%);
        font-size: 140%;  
    }
}

section {
    max-width: 1140px;
    margin: 0 auto;
    padding: 0 1em;
    h1 {
        text-shadow: 1px 1px #000;
    
        @include breakpoint(medium) {
            text-shadow: 3px 3px 2px #000;
        }
    }
}

.breaking-mobile {
 
    @include breakpoint(medium) {
        display: none;
    }
}

.breaking-medium {
    display: none;
  
    @include breakpoint(medium) {
        display: block;
    }
    @include breakpoint(large) {
        display: none;
    }
}

.breaking-large {
    display: none;
  
    @include breakpoint(large) {
        display: block;
    }
}
            
          
!
            
              // Sass Breakpoint Mixin

// for mobile first media queries
// allows for custom breakpoints (which is very powerful), can be adaptated to pixel values if that is your thing

// more info scottnix.com/placement-of-media-queries/ which also includes a SublimeText snippet.

// adaptation of css-tricks.com/media-queries-sass-3-2-and-codekit/

            
          
!
999px
Close

Asset uploading is a PRO feature.

As a PRO member, you can drag-and-drop upload files here to use as resources. Images, Libraries, JSON data... anything you want. You can even edit them anytime, like any other code on CodePen.

Go PRO

Loading ..................

Console