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

              
                <svg class="sprite" viewBox="0 0 100 100" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
    <style type="text/css">
        
        .con__shoe { 
            transform: rotate(var(--shoe-rot, 90deg)); 
            transform-origin: center -100px;
        }
        
        .con__base { fill:var(--base, #3DB39E); }
        .con__body-main { fill:var(--body-main, #EFC75E); }
        .con__body-heel { fill:var(--body-heel, #DCB757); }
        .con__body-top { fill:var(--body-top, #F1CD6E); }
        .con__body-base { fill:var(--body-base, #D7B354); }
        .con__body-heel-base { fill:var(--body-heel-base, #CFAC51); }
        
        .con__logo-circ { fill:var(--logo-circ, #EBEDEE); }
        .con__logo-star { fill:var(--logo-star, #C6584E); }
        
        .con__laces { fill:var(--laces, #FEFEFC); }
        
        .con__toe-cap { fill:var(--toe-cap, #EBEDEE); }
        .con__toe-cap-line { fill:var(--toe-cap-line, #3E4E5C); }
        .con__toe-cap-line-shad { fill:var(--toe-cap-line-shad, #384653); }
        .con__toe-cap-shad { fill:var(--toe-cap-shad, #D3D5D6); }
        
        .con__sole-base { fill:var(--sole-base, #fff); }
        .con__sole-pat { fill:var(--sole-pat, #E5E5E5); }
        
    </style>
    <defs>
        <clipPath id="clip-mask">
            <circle fill="#ffffff" cx="50" cy="50" r="50" />
        </clipPath>
    </defs>
    <symbol id="con">
        <circle class="con__base" cx="50" cy="50" r="50" />        
        <g class="con__shoe" clipPath="url(#clip-mask)">
    
            <g class="con__body">
                <path class="con__body-main" d="M19.232 61.603l2.68-26.548c-.002-.22-.061-1.474-1.228-1.518-.499-.019-.888-.44-.869-.941s.441-.892.938-.874c1.608.061 2.455 1.136 2.791 2.221l19.918-5.92c.428-.118.878.095 1.062.502.111.246 12.165 24.628 34.551 24.628 3.932 0 7.417 3.701 7.879 6.946l.007.028.001.015.018.099c.162 1.405-.265 3.308-1.164 4.534-22.107-.047-49.027.348-66.816.188l.235-3.352-.003-.008z"/>
                <path class="con__body-heel" d="M21.16 64.978l3.008-31.22-.625.186c-.336-1.084-1.183-2.16-2.791-2.221-.496-.019-.918.373-.938.874s.371.922.869.941c1.167.044 1.226 1.297 1.228 1.518l-2.68 26.548.001.009-.235 3.352 2.163.013z"/>
                <path class="con__body-top" d="M86.239 57.957c-1.296-2.539-4.091-4.804-7.165-4.804-22.386 0-34.439-24.382-34.551-24.628-.184-.407-.634-.62-1.062-.502l-2.671.794c7.411 16.646 24.883 28.496 45.449 29.14z"/>
                <path class="con__body-base" d="M86.27 64.006c.307-.618.527-1.315.644-2.008h-67.707l-.141 2.008h67.204z"/>
                <path class="con__body-heel-base" d="M21.447 61.998h-2.24l-.073 1.029-.068.979h2.187z"/>
            </g>

            <g class="con__logo">
                <path class="con__logo-circ" d="M34.002 37.008c-3.866 0-7 3.129-7 6.989 0 3.859 3.134 6.988 7 6.988 3.865 0 7-3.128 7-6.988 0-3.86-3.135-6.989-7-6.989z"/>
                <path class="con__logo-star" d="M30.043 42.977c.069-.206.246-.357.459-.391l2.076-.32.902-1.943c.095-.204.298-.334.521-.334.223 0 .426.13.521.334l.902 1.943 2.075.32c.214.033.391.185.459.391.069.207.017.436-.134.591l-1.521 1.575.354 2.185c.035.22-.057.441-.236.569-.1.071-.216.106-.332.106-.096 0-.191-.024-.279-.073l-1.809-1.01-1.81 1.01c-.087.048-.183.073-.278.073-.117 0-.232-.036-.332-.106-.18-.128-.271-.35-.236-.569l.353-2.185-1.521-1.575c-.151-.156-.202-.384-.134-.591z"/>
            </g>

            <path class="con__laces" d="M52.619 37.381c-.502-.498-1.314-.498-1.816 0l-2.422 2.405c-.502.498-.502 1.306 0 1.803.501.498 1.314.498 1.816 0l2.422-2.405c.502-.497.502-1.305 0-1.803zm4 4c-.502-.499-1.314-.499-1.816 0l-2.422 2.405c-.502.498-.502 1.306 0 1.803.501.498 1.314.498 1.816 0l2.422-2.405c.502-.497.502-1.305 0-1.803zm4 4c-.502-.498-1.314-.498-1.816 0l-2.422 2.405c-.502.498-.502 1.305 0 1.803.501.498 1.314.498 1.816 0l2.422-2.405c.502-.497.502-1.305 0-1.803z"/>

            <g class="con__toe">
                <path class="con__toe-cap" d="M86.979 60.241l-.018-.099-.001-.015-.007-.028c-.462-3.245-3.947-6.946-7.879-6.946-2.76 0-5.36-.373-7.803-1.023-1.66 2.422-2.667 5.554-2.667 8.982 0 1.281.151 2.516.413 3.693 5.749-.026 11.416-.042 16.797-.03.9-1.226 1.327-3.129 1.165-4.534z"/>
                <path class="con__toe-cap-line" d="M69.354 61.112c0-3.385 1.032-6.464 2.71-8.795-.521-.124-1.034-.259-1.541-.407-1.666 2.517-2.669 5.717-2.669 9.202 0 1.279.148 2.514.401 3.696l1.525-.006c-.272-1.172-.426-2.407-.426-3.69z"/>
                <path class="con__toe-cap-shad" d="M68.655 61.998c.037.685.113 1.354.228 2.008h17.387l.001-.002c.152-.308.283-.634.391-.97l.004-.014c.105-.333.188-.675.246-1.016l.002-.007h-18.259z"/>
                <path class="con__toe-cap-line-shad" d="M68.125 64.006h1.493c-.118-.652-.199-1.322-.237-2.008h-1.477c.036.684.11 1.353.221 2.008z"/>
            </g>

            <g class="con__sole">
                <path class="con__sole-base" d="M86.353 62.986h-66.706c-.91 0-1.647.717-1.647 1.601v.8c0 .884.737 1.6 1.647 1.6h66.706c.909 0 1.647-.716 1.647-1.6v-.8c0-.884-.738-1.601-1.647-1.601z"/>
                <path class="con__sole-pat" d="M42.018 62.986h1.969v4h-1.969zM37.018 62.986h1.969v4h-1.969zM32.018 62.986h1.969v4h-1.969zM27.018 62.986h1.969v4h-1.969zM22.017 62.986h1.969v4h-1.969zM52.018 62.986h1.969v4h-1.969zM47.018 62.986h1.969v4h-1.969zM57.018 62.986h1.969v4h-1.969zM77.018 62.986h1.969v4h-1.969zM82.018 62.986h1.969v4h-1.969zM72.018 62.986h1.969v4h-1.969zM67.018 62.986h1.969v4h-1.969zM62.018 62.986h1.969v4h-1.969z"/>
            </g>
        
        </g>  
    </symbol>
</svg>

<div class="container">
    <h1 class="title">Styling and animating SVG &lt;use&gt; icons via CSS custom properties.</h1>
    <div class="examples">
        <div class="col">
            <svg class="icon icon--1">
                <use xlink:href="#con"></use>
            </svg>
            <p class="col__title">Default</p>
        </div>
        <div class="col">
            <svg class="icon icon--2">
                <use xlink:href="#con"></use>
            </svg>
            <p class="col__title">Custom<br />Colour</p>
        </div>
        <div class="col">
            <svg class="icon icon--3">
                <use xlink:href="#con"></use>
            </svg>
            <p class="col__title">Animated<br />Colour</p>
        </div>
        <div class="col">
            <svg class="icon icon--4">
                <use xlink:href="#con"></use>
            </svg>
            <p class="col__title">Animated<br />Transforms</p>
        </div>   
    </div>
</div>
              
            
!

CSS

              
                html {
	box-sizing: border-box;
}

*, *:before, *:after {
	box-sizing: inherit;
}

html, body {
	width: 100%;
	height: 100%;
}

body {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: auto;
    background-color: #272B2C;
    color: white;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-family: Helvetica, sans-serif;
}

.sprite {
    display: none;
}

.container {
    padding: 30px;
	visibility: hidden;
}

.examples {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
}

.title {
    font-size: 24px;
    margin: 0 auto 40px;
    max-width: 500px;
    text-align: center;
}

.icon { // default styling
    --base: #3DB39E;
    // Canvas body
    --body-main: #EFC75E;
    --body-heel: #DCB757;
    --body-heel-base: #CFAC51;
    --body-top: #F1CD6E;
    --body-base: #D7B354;
    // Logo
    --logo-circ: #EBEDEE;
    --logo-star: #C6584E;
    // Laces
    --laces: #fff;
    // Toe Cap
    --toe-cap: #EBEDEE;
    --toe-cap-line: #3E4E5C;
    --toe-cap-line-shad: #384653;
    --toe-cap-shad: #D3D5D6;
    // Sole
    --sole-base: #fff;
    --sole-pat: #E5E5E5;
    // Rotation
    --shoe-rot: 0;
    
    width: 100px;
    height: 100px;
    margin: 10px;
}

// styling overridden
.icon--2,
.icon--4 {
    --base: #E43737;
    // Canvas body
    --body-main: #222222;
    --body-heel: #000;
    --body-heel-base: #000;
    --body-top: #313131;
    --body-base: #000;
}


.col__title {
    font-size: 12px;
    font-weight: 400;
    margin: 0;
    text-align: center;
    height: 40px;
    opacity: 0.5;
    line-height: 1.5;
}
              
            
!

JS

              
                console.clear();

select = e => document.querySelector(e);
selectAll = e => document.querySelectorAll(e);

const container = select('.container');

function colorShoe3() {
    tl = gsap.timeline();
    
    tl.to('.icon--3', {
        '--base': '#E43737',
        '--body-main': '#222222',
        '--body-heel': '#000',
        '--body-top': '#313131',
        '--body-base': '#000',
        duration: 2,
        yoyo: true,
        repeat: -1,
        repeatDelay: 1,
        ease: 'sine.inOut'
    })
}

function animShoe4() {
    tl = gsap.timeline();
    
    tl.fromTo('.icon--4', {
        '--shoe-rot': '10deg'
    },{
        '--shoe-rot': '-10deg',
        transformOrigin: "center center",
        duration: 1,
        yoyo: true,
        repeat: -1,
        ease: 'sine.inOut'
    })
}

function init() {
    gsap.set(container, { autoAlpha: 1 });
    colorShoe3();
    animShoe4();
}

window.onload = () => {
	init();
};
              
            
!
999px

Console