Pen Settings

HTML

CSS

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

JavaScript

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

Packages

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.

Behavior

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.

HTML

              
                <p>Negative/defensive use of <code>prefers-reduced-motion</code>: only run animations in browsers that <em>do</em> support the media feature - and there, only if they have <em>not</em> expressed a preference for reduced motion, i.e. <code>(prefers-reduced-motion:no-preference)</code> evaluates to true. In older browsers (such as IE11) where users can't signal their preference, simply don't animate.</p>

<div class="animation">animated box</div>

<pre><code>@media (prefers-reduced-motion: no-preference) {
  .animation {
    animation: vibrate 0.3s linear infinite both; 
  }
}</code></pre>

<p>To clarify, this is the exact opposite of most current approaches, where an animation is defined, and then suppressed if <code>(prefers-reduced-motion:reduce)</code> evaluates to true.</p>

<pre><code>.animation {
  animation: vibrate 0.3s linear infinite both; 
}

@media (prefers-reduced-motion: reduce) {
  .animation {
    animation: none;
  }
}</code></pre>

<p>The issue with that approach is that in browsers that <em>don't</em> support the <code>prefers-reduced-motion</code> media feature, there's no way for users to then turn animations off. Instead, with the defensive approach, in these cases animations won't run either.</p>

<p>Based on <a href="https://twitter.com/derSchepp/status/1202223608719908865" target="_blank">this idea by Christian Schaefer</a>. Example code/CSS from <a href="https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-reduced-motion" target="_blank">MDN's <code>prefers-reduced-motion</code> reference</a>.</p>
              
            
!

CSS

              
                /* only run animation explicitly in browsers that support prefers-reduced-motion itself. old browsers (IE11 etc) won't get any animation. */

@media (prefers-reduced-motion: no-preference) {
  .animation {
    animation: vibrate 0.3s linear infinite both; 
  }
}


.animation {
  background-color: rebeccapurple;
  color: #fff;
  font: 1.2em Helvetica, arial, sans-serif;
  width: 200px;
  padding: 1em;
  border-radius: 1em;
  text-align: center;  
}

/* ----------------------------------------------
 * Generated by Animista on 2018-9-2 13:47:0
 * w: http://animista.net, t: @cssanimista
 * ---------------------------------------------- */

/**
 * ----------------------------------------
 * animation vibrate-1
 * ----------------------------------------
 */

@keyframes vibrate {
  0% {
            transform: translate(0);
  }
  20% {
            transform: translate(-2px, 2px);
  }
  40% {
            transform: translate(-2px, -2px);
  }
  60% {
            transform: translate(2px, 2px);
  }
  80% {
            transform: translate(2px, -2px);
  }
  100% {
            transform: translate(0);
  }
}

/* some generic styles for the demo explanation itself */

p code, pre { background: #f5f5f5; border: #ddd solid 1px; }
p code { padding: 0 0.25em; margin: 0 0.15em; }
pre { padding: 1em 1.5em; }
              
            
!

JS

              
                
              
            
!
999px

Console