Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Behavior

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.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <link href='https://fonts.googleapis.com/css?family=Roboto:100,300,700' rel='stylesheet' type='text/css'>

<header>
  <h1>Mobile-first Nested Media Queries</h1>
  <h2>Using Sass Maps</h2>
  <p>Resize me, please.</p>
</header>

<div class="primary">
  <h3></h3>
  <p>Primary container.</p>
</div>
<div class="secondary">
  <h3>I am a sidebar.</h3>
  <p>Secondary container</p>
</div>

              
            
!

CSS

              
                // Name and define our breakpoints
$breakpoints: (
  small: 24em,
  medium: 34em,
  large: 44em
);

@mixin wider-than($screen-size) {
	@if map-has-key($breakpoints, $screen-size) {
		@media (min-width: map-get($breakpoints, $screen-size)) {
			@content;
		}
	} @else {
		// Debugging
		@warn "'#{$screen-size}' has not been declared as a breakpoint."
	}
}

/* Color Variables */
$color-large: #F45D4C;
$color-medium: #F7A541;
$color-small: #FFC52C;
$color-primary: #B3CC57;
$color-title: #6E6460;
$color-subtitle: #BCBCBC;

/*--------------------------
  Layout with breakpoints
  --------------------------*/

.primary,
.secondary {
  box-sizing: border-box;
  float: none;
  margin: 0 auto;
}

.primary {
  background-color: $color-primary;
  width: 100%;

  @include wider-than(small) {
    background-color: $color-small;
    float: left;
    width: 55%;
  }

  @include wider-than(medium) {
    background-color: $color-medium;
    width: 65%;
  }

  @include wider-than(large) {
    background-color: $color-large;
    width: 75%;
  }
}

.secondary {
  background-color: #999;
  width: 100%;

  @include wider-than(small) {
    float: right;
    width: 45%;
  }

  @include wider-than(medium) {
    width: 35%;
  }

  @include wider-than(large) {
    width: 25%;
  }

  @include wider-than(made-up-size) {
    width: 15%;
  }
}


/*--------------------------
  Making it pretty 
  --------------------------*/

.primary,
.secondary {
  color: #fff;
  padding: 1em;
}

h1, h2, h3, p {
  font-family: 'Roboto', sans-serif;
  line-height: 1.25;
  margin: 0 auto;
}

header {
  margin: 2em auto;
  text-align: center;
}

h1 {
  color: $color-title;
  font-size: 2em;  
  font-weight: 100;
  
  @include wider-than(medium) {
     font-size: 3em;
  }
}

h2 {
  color: $color-subtitle;
  font-size: 1.5em;
  font-weight: 700;

  @include wider-than(medium) {
    font-size: 1.75em;
  }
}

h3, p {
  font-size: 1.0em;
  font-weight: 100;
}

/* Just for fun, showing breakpoint name */
.primary h3:before {
  content: "I am default, mobile first. ";
  font-weight: 700;

  @include wider-than(small) {
      content: "Wider than small. ";
  }

  @include wider-than(medium) {
      content:"Wider than medium. ";
  }

  @include wider-than(large) {
      content: "Wider than large. ";
  }
}

              
            
!

JS

              
                
              
            
!
999px

Console