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.


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.


                <div class="container">
  <h1>Animating CSS Masks: Works in Webkit, but not in Firefox or IE</h1>

  <p>CSS Mask Animation</p>

  <img src="">

  <div class="button-wrapper">


                html {
  box-sizing: border-box;

*:after {
  box-sizing: inherit;

body {
  font-family: sans-serif;
  font-weight: 400;
  margin: 0;
  padding: 0;
  background-color: aliceblue;
  color: white;

.container {
  max-width: 90%;
  margin: 0 auto;
  text-align: center;
  color: lightskyblue

img {
  position: relative;
  display: block;
  max-width: 100%;
  height: auto;
  margin: 0 auto;
  padding: 0;
  z-index: 1;
  mask: url( 50% 10% / 80% no-repeat;

p {
  position: absolute;
  top: 30%;
  left: 50%;
  transform: translate(-50%, -30%);
  font-size: 46px;
  text-align: center;
  z-index: 2;
  font-weight: 800;
  color: lightseagreen;
  opacity: 0;
  transition: opacity 0.5s ease-in-out 1.5s;
  mix-blend-mode: screen;

/* add this class to make paragraph visible on the mask */

.visible {
  opacity: 1;
  visibility: visible;

.button-wrapper {
  padding: 2em;
  text-align: center;
  position: relative;
  top: 0;
  z-index: 10;

.button-wrapper button {
  text-transform: uppercase;
  font-weight: 800;
  background-image: none;
  padding: 1em;
  cursor: pointer;
  background-color: transparent;
  color: lightseagreen;
  border: 2px solid lightseagreen;

/* add this class to animate mask position and size and rotate it */

.animate {
  transform: rotate(360deg);
  animation: move 0.5s ease;

/* CSS animation */

@keyframes move {
  0% {
    mask-position: 0 0;
    mask-size: 30%;
    transform: rotate(10deg);
  100% {
    mask-position: 50% 10%;
    mask-size: 100% 80%;
    mask-size: 80%;
    transform: rotate(360deg);


                //store elements in variables
var mask = document.querySelector('img'),
  paragraph = document.querySelector('p'),
  btn = document.querySelector('button');

//add event listener to animate button to add the relevant CSS classes to the appropriate elements to animate them
btn.addEventListener('click', function(e) {
}, false);

//remove animation classes 
function removeAnimation(elem, animClass) {
mask.addEventListener('animationend', function() {
  removeAnimation(this, 'animate');
}, false);

//remove class that transitions the paragraph after transition ends
paragraph.addEventListener('transitionend', function() {
  removeAnimation(this, 'visible');
}, false);