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 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

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

              
                <div class="wrapper">
  
  <h3>Little expriment I made to play with SVG animations.</h3>

	<button type="button" id="animation-trigger">Replay Animation</button>

	<svg xmlns="http://www.w3.org/2000/svg" width="400" height="400" viewBox="0 0 400 400" class="wp-logo animate">
		<circle class="wp-logo__circle" cx="200" cy="200" r="194" fill="none" stroke="#464342" stroke-width="12" transform="rotate(-90, 200, 200)" />
		<g class="wp-logo__doubleyou" width="400" height="400">
			<path class="path" fill="#464342" d="M125.12 354.4c-8.18-22.42-73.65-201.81-81.84-224.23-9.52 21.33-14.85 44.95-14.85 69.82 0 67.91 39.46 126.6 96.69 154.41z" />
			<path class="path" fill="#464342" d="M302.26 143.61c-8.7-14.13-16.85-26.1-16.85-40.23 0-15.77 11.96-30.45 28.81-30.45.76 0 1.48.09 2.22.13-30.52-27.96-71.19-45.03-115.86-45.03-59.93 0-112.67 30.75-143.34 77.33 4.02.12 7.81.2 11.04.2 17.94 0 45.72-2.17 45.72-2.17 9.25-.55 10.34 13.04 1.1 14.13 0 0-9.29 1.09-19.64 1.63 4.17 12.39 25 74.34 62.48 185.84l37.55-112.6-26.73-73.24c-9.24-.54-17.99-1.64-17.99-1.64-9.25-.54-8.17-14.68 1.08-14.13 0 0 28.33 2.18 45.19 2.18 17.94 0 45.73-2.18 45.73-2.18 9.25-.55 10.34 13.04 1.1 14.13 0 0-9.32 1.1-19.64 1.64 4.13 12.29 24.8 73.77 62 184.43 10.27-34.31 15.97-53.38 17.11-57.19 7.42-23.73 13.06-40.77 13.06-55.46 0-21.2-7.61-35.89-14.14-47.32z" />
			<path class="path" fill="#464342" d="M151.53 364.58c15.37 4.52 31.62 6.99 48.47 6.99 19.97 0 39.13-3.46 56.97-9.73-.46-.73-.88-1.51-1.22-2.36-3.52-9.63-21.1-57.79-52.74-144.48-30.89 89.75-48.05 139.61-51.48 149.58z" />
			<path class="path" fill="#464342" d="M351.69 135.32c0 17.41-3.25 36.98-13.04 61.45l-52.41 151.52c51.01-29.74 85.32-85 85.32-148.3 0-29.83-7.62-57.87-21.02-82.31.74 5.46 1.15 11.33 1.15 17.64z" />
		</g>
	</svg>

</div>

              
            
!

CSS

              
                .wrapper {
	margin: 30px auto;
	text-align: center;
	width: 500px;
}

#animation-trigger {
	display: block;
	margin: 15px auto;
	background-color: #1392db;
	border: 0;
	color: #fff;
	padding: 10px 15px;
	transition: all .3s;
	text-transform: uppercase;
	cursor: pointer;
	box-shadow: 0px 1px 3px #666;
	
	&:hover {
		transform: translateY(-3px);
	}

	&:active {
		transform: translateY(1px);
	}

}

.wp-logo {
	height: auto;
	width: 200px;

	&__circle {
		fill: transparent;
		stroke-dasharray: 1219; /* Circumference (2*pi*r) */
		stroke-dashoffset: 0;
		transition: all 2s;
	}

	&__doubleyou {
		transform-origin: center center;
	}

	.animate & {

		&__circle {
			animation: draw 2s;
		}

		&__doubleyou {
			animation: rotation 2s;
		}

	}

}

@keyframes draw {
	from { stroke-dashoffset: 1219; }
	to { stroke-dashoffset: 0; }
}

@keyframes rotation {
	from {
		opacity: 0;
		transform: rotate(0deg) scale(0);
	}
	to {
		opacity: 1;
		transform: rotate(360deg) scale(1);
	}
}
              
            
!

JS

              
                // Declare our variables holding our elements
var trigger = document.getElementById('animation-trigger');
var logo    = document.querySelector('.wp-logo');

// Hook event listeners
trigger.addEventListener( 'click', function(){ toggleClass( logo, 'animate' ) } );
logo.addEventListener( 'animationend', function(){ removeClass( logo, 'animate' ) } );

/** DEFINE HELPER FUNCTIONS **/

/**
 * Toggles a given class
 * Note: set defaults for example purposes only
 *
 * @param  {domObject} element  Element to toggle the class on.
 * @param  {String} ourClass    Our class to toggle on the element
 */
function toggleClass( element = this, ourClass = 'active' ) {

    if ( element.classList ) {
        element.classList.toggle( ourClass );
    } else {
        // For when classList isn't supported
        var classes = element.className.split(' '),
            i       = classes.indexOf( ourClass );

        if ( i >= 0 )
            classes.splice(i, 1);
        else
            classes.push( ourClass );
            element.className = classes.join(' ');
    }

}

/**
 * Remove a specific class
 *
 * @param  {domObject} element  Element to remove the class on.
 * @param  {String} ourClass    Our class to remove on the element
 */
function removeClass( element = this, ourClass = 'active' ) {
    if ( element.classList ) {
        element.classList.remove(ourClass);
    } else {
        // For when classList isn't supported
        element.className.replace( /(?:^|\s)ourClass(?!\S)/g , '' );
    }
}
              
            
!
999px

Console