Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource


Babel includes JSX processing.

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


Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.


Auto Save

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.


                <div class="notice"></div>

<div class="article-block js-bgimg" style="background-image: url('')" data-bgimg="" data-bgimg-retina="" data-bgimg-large="" data-bgimg-large-retina="">
  <div class="article-block__body">
    <h1>Blue Heaven on Earth</h1>


                body { padding: 2em; }

h1 {
  color: white;
  margin: 0;

.notice {
  background: gray;
  margin-bottom: 2em;
  padding: 0.5em;
  color: white;
  border-radius: 5px;

.article-block {
  position: relative;
  background-size: cover;
  background-repeat: no-repeat;
  background-position: center;
  padding: 2em;
  min-height: 320px;
  border-radius: 1em;
  overflow: hidden;

.article-block__body {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 1.5em;
  background: rgba(0,0,0,.3);


 * enquire.js v2.1.2 - Awesome Media Queries in JavaScript
 * Copyright (c) 2014 Nick Williams -
 * License: MIT (

!function(a,b,c){var d=window.matchMedia;"undefined"!=typeof module&&module.exports?module.exports=c(d):"function"==typeof define&&define.amd?define(function(){return b[a]=c(d)}):b[a]=c(d)}("enquire",this,function(a){"use strict";function b(a,b){var c,d=0,e=a.length;for(d;e>d&&(c=b(a[d],d),c!==!1);d++);}function c(a){return"[object Array]"===Object.prototype.toString.apply(a)}function d(a){return"function"==typeof a}function e(a){this.options=a,!a.deferSetup&&this.setup()}function f(b,c){this.query=b,this.isUnconditional=c,this.handlers=[],this.mql=a(b);var d=this;this.listener=function(a){d.mql=a,d.assess()},this.mql.addListener(this.listener)}function g(){if(!a)throw new Error("matchMedia not present, legacy browsers require a polyfill");this.queries={},this.browserIsIncapable=!a("only all").matches}return e.prototype={setup:function(){this.options.setup&&this.options.setup(),this.initialised=!0},on:function(){!this.initialised&&this.setup(),this.options.match&&this.options.match()},off:function(){this.options.unmatch&&this.options.unmatch()},destroy:function(){this.options.destroy?this.options.destroy()},equals:function(a){return this.options===a||this.options.match===a}},f.prototype={addHandler:function(a){var b=new e(a);this.handlers.push(b),this.matches()&&b.on()},removeHandler:function(a){var c=this.handlers;b(c,function(b,d){return b.equals(a)?(b.destroy(),!c.splice(d,1)):void 0})},matches:function(){return this.mql.matches||this.isUnconditional},clear:function(){b(this.handlers,function(a){a.destroy()}),this.mql.removeListener(this.listener),this.handlers.length=0},assess:function(){var a=this.matches()?"on":"off";b(this.handlers,function(b){b[a]()})}},g.prototype={register:function(a,e,g){var h=this.queries,i=g&&this.browserIsIncapable;return h[a]||(h[a]=new f(a,i)),d(e)&&(e={match:e}),c(e)||(e=[e]),b(e,function(b){d(b)&&(b={match:b}),h[a].addHandler(b)}),this},unregister:function(a,b){var c=this.queries[a];return c&&(b?c.removeHandler(b):(c.clear(),delete this.queries[a])),this}},new g});

// begin custom function

function img() {
  $('.js-bgimg').each(function() {
    var bgImg = $(this);
    var imgStandard ='bgimg');
    var imgRetina ='bgimg-retina');
    var imgLarge ='bgimg-large');
    var imgLargeRetina ='bgimg-large-retina');
    // simple function to replace background image
    function replaceImg(el, replacementImg) {
      el.attr('style', 'background-image: url("'+ replacementImg +'")');
    // where are we? I set this up so you can what state is active in enquire.
    $('.notice').text('No enquire states, yet.');
      // when min-width: 62em registers, run this code
      .register("screen and (min-width: 62em)", {
        match : function() {
          // update our notice, it matches
          // now we just update the image for our large image
          replaceImg(bgImg, imgLarge);
        // if the screen gets smaller, it'll "unmatch" from our media query
        unmatch : function() {
          // update the notice! no longer matching.
          // let's use our standard square image
          replaceImg(bgImg, imgStandard);
        // we need to test for retina on setup
        setup : function() {
          // we can use matchmedia to test if we have retina or not.
          // since the standard image is pre-loaded in mark-up, we only need to test for retina
          if (matchMedia('screen and (-webkit-min-device-pixel-ratio: 2), screen and (min-resolution: 192dpi)').matches) {
            // update our notice
            $('.notice').text('setup officially official');
            // update our image for retina!
            replaceImg(bgImg, imgRetina);  
      // okay, now we're testing our screen width AND for retina images.
      .register("screen and (min-width: 62em) and (-webkit-min-device-pixel-ratio: 2), screen and (min-width: 62em) and (min-resolution: 192dpi)", {
        match : function() {
          // let's update the notice
          $('.notice').text('retina match');
          // we have retina and a large screen, let's use the large retina graphic
          replaceImg(bgImg, imgLargeRetina);
        unmatch : function() {
          // update the notice
          $('.notice').text('retina unmatch');
          // no longer in a wide screen, so update the image to be our square retina graphic
          replaceImg(bgImg, imgRetina);