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

              
                h2 'Hero' buttons with animated icons
h3 Three sizes : )

.display

    // default size
    .flexbox.default
        .display-box
            .hero-icon.red.bolt-strike
                i.main.fa.fa-bolt

        .display-box
            .hero-icon.deeppurple.bomb-boom
                i.main.fa.fa-bomb

        .display-box
            .hero-icon.huntergreen.change-spock
                i.main.fa.fa-hand-stop-o

        .display-box
            .hero-icon.pink.rocket-flight
                i.main.fa.fa-rocket

        .display-box
            .hero-icon.yellow.science-shake
                i.main.fa.fa-flask
                .science-bubbles
                    i.bubble.fa.fa-circle
                    i.bubble.fa.fa-circle
                    i.bubble.fa.fa-circle

        .display-box
            .hero-icon.green.punch
                i.main.fa.fa-hand-rock-o

        .display-box
            .hero-icon.skyblue.gavel-strike
                i.main.fa.fa-gavel

        .display-box
            .hero-icon.tan.coffee-cup
                i.main.fa.fa-coffee
                .cup-steam
                    i.steam.fa.fa-fire

        .display-box
            .hero-icon.lavendar.brush-strokes
                i.main.fa.fa-paint-brush

        .display-box
            .hero-icon.teal.center-spin
                i.main.fa.fa-wifi

        .display-box
            .hero-icon.orange.drip
                i.main.fa.fa-tint

        .display-box
            .hero-icon.melon.spin-forever
                i.main.fa.fa-safari
    
    // medium size
    .flexbox.medium
        .display-box
            .hero-icon.red.bolt-strike.medium
                i.main.fa.fa-bolt

        .display-box
            .hero-icon.deeppurple.bomb-boom.medium
                i.main.fa.fa-bomb

        .display-box
            .hero-icon.huntergreen.change-spock.medium
                i.main.fa.fa-hand-stop-o

        .display-box
            .hero-icon.pink.rocket-flight.medium
                i.main.fa.fa-rocket

        .display-box
            .hero-icon.yellow.science-shake.medium
                i.main.fa.fa-flask
                .science-bubbles
                    i.bubble.fa.fa-circle
                    i.bubble.fa.fa-circle
                    i.bubble.fa.fa-circle

        .display-box
            .hero-icon.green.punch.medium
                i.main.fa.fa-hand-rock-o

        .display-box
            .hero-icon.skyblue.gavel-strike.medium
                i.main.fa.fa-gavel

        .display-box
            .hero-icon.tan.medium.coffee-cup
                i.main.fa.fa-coffee
                .cup-steam
                    i.steam.fa.fa-fire

        .display-box
            .hero-icon.lavendar.medium.brush-strokes
                i.main.fa.fa-paint-brush

        .display-box
            .hero-icon.teal.center-spin.medium
                i.main.fa.fa-wifi

        .display-box
            .hero-icon.orange.medium.drip
                i.main.fa.fa-tint

        .display-box
            .hero-icon.melon.medium.spin-forever
                i.main.fa.fa-safari
    
    // small size
    .flexbox.small
        .display-box
            .hero-icon.red.bolt-strike.small
                i.main.fa.fa-bolt

        .display-box
            .hero-icon.deeppurple.bomb-boom.small
                i.main.fa.fa-bomb

        .display-box
            .hero-icon.huntergreen.change-spock.small
                i.main.fa.fa-hand-stop-o

        .display-box
            .hero-icon.pink.rocket-flight.small
                i.main.fa.fa-rocket

        .display-box
            .hero-icon.yellow.science-shake.small
                i.main.fa.fa-flask
                .science-bubbles
                    i.bubble.fa.fa-circle
                    i.bubble.fa.fa-circle
                    i.bubble.fa.fa-circle

        .display-box
            .hero-icon.green.small.punch
                i.main.fa.fa-hand-rock-o

        .display-box
            .hero-icon.skyblue.small.gavel-strike
                i.main.fa.fa-gavel

        .display-box
            .hero-icon.tan.small.coffee-cup
                i.main.fa.fa-coffee
                .cup-steam
                    i.steam.fa.fa-fire

        .display-box
            .hero-icon.lavendar.small.brush-strokes
                i.main.fa.fa-paint-brush

        .display-box
            .hero-icon.teal.small.center-spin
                i.main.fa.fa-wifi

        .display-box
            .hero-icon.orange.small.drip
                i.main.fa.fa-tint

        .display-box
            .hero-icon.melon.small.spin-forever
                i.main.fa.fa-safari
              
            
!

CSS

              
                @import url(https://fonts.googleapis.com/css?family=Source+Sans+Pro:300);

$scaleSmall: 1.2em;
$scaleMedium: 1.8em;
$scaleDefault: 2.5em;

$backgroundColor: #1a1a1a;
$lightIconColor: white;
$darkIconColor: $backgroundColor;

$heroBaseRed: #9E0031;
$heroBaseYellow: #FFE066;
$heroBaseGreen: #4ADF62;
$heroBaseSkyBlue: #86BBD8;
$heroBaseDeepPurple: #6622CC;
$heroBaseHunterGreen: #4E6B64;
$heroBaseTan: #ACAD94;
$heroBasePink: #E15A97;
$heroBaseLavendar: #774C60;
$heroBaseTeal: #1B998B;
$heroBaseOrange: #D6403E;
$heroBaseMelon: #003249;

// base page styles
body,html{
    box-sizing: border-box;
    margin: 0;
    width: 100vw;
    height: 100vh;
    font-family: "Source Sans Pro" sans-serif;
    background-color: $backgroundColor;
}

h2 {
    text-align: center;
    color: white;
    font-size: 2em;
}

h3 {
    text-align: center;
    color: white;
    font-size: 1.5em;
}



.display {
    display: flex;
    justify-content: center;
    flex-direction: column;
    align-items: center;
}

.flexbox {
    display: flex;
    flex-flow: row wrap;
    justify-content: center;
    margin: 2.5em 2em 0 2em;
    
    &.default { max-width: 45em; }
    &.medium { max-width: 38em; }
    &.small { max-width: 28em; }
}



.display-box {
    margin: 2em;
}

// mixin that makes it all happen
// all colors are based on $baseColor, icon color is $fontColor,
// and the percentage variables tell us how much to darken/lighten the base color
// for each of the 3 rings that appear on hover
@mixin heroIcon ($baseColor, $fontColor, $borderPerc, $ring1Perc, $ring2Perc, $ring3Perc) {
    background: $baseColor;
    border-color: darken($baseColor, $borderPerc);
    color: $fontColor;
    
    $ring1Color: darken($baseColor, $ring1Perc);
    $ring2Color: darken($baseColor, $ring2Perc);
    $ring3Color: lighten($baseColor, $ring3Perc);
    box-shadow: 0 0 15px rgba(white, 0.2);
    
    &:hover {
        box-shadow: 0 0 1px 0.4em rgba($ring1Color, 1),
            0 0 1px 0.8em rgba($ring2Color, 0.8),
            0 0 1px 1.2em rgba($ring3Color, 0.3);
    }
}

@mixin emScale ($scaleValue) {
    font-size: $scaleValue;
}

@mixin scienceBubble($top, $left, $fontSize, $duration, $scale) {
    top: ($top * $scale);
    left: ($left * $scale); 
    font-size: ($fontSize * $scale);
    opacity: 0;
    animation-duration: $duration;
    animation-name: none;
}
    

// simple animation to scale the icon up and then back down to normal size
// the animation is only applied on hover and only plays once per hover
@keyframes scaleUpAndDown {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(2);
    }
    100% {
        transform: scale(1);
    }
}

@keyframes boltStrike {
    0% {
        top: -1.45em;
    }
    40% {
        top: -1.45em;
    }
    55% {
        top: 0;
    }
    70% {
        top: 0.45em;
    }
    100% {
        top: 0.45em;
    }
}

@keyframes spinAroundToNeutral {
    0% {
        transform: rotate(0deg);
        top: 0;
    }
    99% {
        top: 0;
    }
    100% { 
        transform: rotate(360deg);
        position: relative;
        top: 0.4em;
    }
}

@keyframes spinAround {
    0% {
        transform: rotate(0deg) scale(1.2);
    }
    100% { 
        transform: rotate(360deg) scale(1.2);
    }
}

@keyframes bombBoom {
    0% {
        transform: scale(1) rotate(0deg);
    }
    15% {
        transform: scale(1.3) rotate(-10deg);
    }
    25% {
        transform: scale(1.1) rotate(-30deg);
    }
    35% {
        transform: scale(1.4) rotate(-25deg);
    }
    45% {
        transform: scale(1.2) rotate(5deg);
    }
    50% {
        transform: scale(1.4) rotate(-15deg);
    }
    65% {
        transform: scale(1.5) rotate(5deg);
        opacity: 0.7;
    }
    95% {
        transform: scale(2) rotate(-40deg);
        opacity: 0.4;
    }
    100% {
        opacity: 0;
    }
}

@keyframes gavelStrike {
    0% {
        transform: scale(1.2) rotate(0deg);
    }
    49% {
        transform: scale(1.2) rotate(0deg);
    }
    
    50% {
        transform: scale(1.2) rotate(-45deg);
    }
    85% {
        transform: scale(1.2) rotate(-45deg);
    }
    100% {
        transform: scale(1.2) rotate(0deg);
    }
}

@keyframes rocketFlight {
    0% {
        transform: rotate(0deg);
        left: 0.49em;
        top: 0.45em;
    }
    30% {
        top: -1.5em;
        left: 1.8em;
        transform: scale(0.9);
    }
    35% {
        opacity: 0;
        top: 2.45em;
        left: -1.8em;
    }
    40% {
        opacity: 1;
    }
    100% {
        transform: rotate(0deg) scale(1);
        left: 0.49em;
        top: 0.45em;
    }
}

@keyframes scienceShake {
    0% {
        left: 0.49em;
        top: 0.45em;
    }
    29% {
        transform: rotate(0deg);
    }
    30% {
        top: 0.55em;
        transform: rotate(-8deg);
    }
    40% {
        transform: rotate(0deg);
    }
    50% {
        transform: rotate(8deg);
    }
    60% {
        transform: rotate(0deg);
    }
    70% {
        transform: rotate(-8deg);
    }
    100% {
        transform: rotate(0deg);
        left: 0.49em;
        top: 0.45em;
    }
}

@keyframes bubbleRise {
    0% {
        opacity: 0;
    }
    40% {
        transform: scale(1.1);
        opacity: 0.7;
    }
    50% {
        transform: scale(1.05);
        opacity: 0.8;
    }
    90% {
        opacity: 0.3;
    }
    100% {
        transform: scale(1);
        opacity: 0.1;
    }
}

@keyframes punchUp {
    0% {
        top: 0.45em;
    }
    25% {
        top: 0.65em;
    }
    64% {
        top: 0.65em;
    }
    65% {
        top: -0.25em;
    }
    100% {
        top: 0.65em;
    }
}

@keyframes coffeeSteam {
    0% {
        top: 0.3em;
        left: 1.5em;
    }
    25% {
        top: 0.25em;
        left: 1.4em;
    }
    50% {
        top: 0.25em;
        left: 1.5em;
    }
    75% {
        top: 0.3em;
        left: 1.4em;
    }
    100% {
        top: 0.3em;
        left: 1.5em;
    }
}

@keyframes brushStrokes {
    0% {
        transform: rotate(0deg);
    }
    25% {
        transform: rotate(-55deg);
    }
    50% {
        transform: rotate(-110deg);
    }
    75% {
        transform: rotate(-55deg);
    }
    100% {
        transform: rotate(0deg);
    }
}

@keyframes drip {
    0% {
        top: 0.45em;
    }
    35% {
        top: 0.45em;
        transform: scale(0.9);
        opacity: 0.9;
    }
    40% {
        top: 1.75em;
        transform: scale(0.7);
        opacity: 0;
    }
    70% {
        opacity: 0;
        top: -2em;
    }
    90% {
        opacity: 0;
        transform: scale(1);
        top: 0em;
    }
    100% {
        opacity: 1;
        top: 0.45em;
    }
}

// base styles shared by all hero icons
.hero-icon {
    position: relative;
    width: 1.9em;
    height: 1.9em;
    line-height: 1.9em;
    border-radius: 50%;
    border: 0.15em solid transparent;
    text-align: center;
    transition: box-shadow 300ms cubic-bezier(.2,0,.7,1), 
                transform 300ms cubic-bezier(.2,0,.7,1),
                border-width 300ms cubic-bezier(.2,0,.7,1);
    
    // special styles for the flask bubbles :/
    i.bubble {
        &:nth-of-type(1) { @include scienceBubble(0.65, 1.5, .085, 0.7s, $scaleDefault); }
        &:nth-of-type(2) { @include scienceBubble(0.25, 1.675, .09, 0.8s, $scaleDefault); }
        &:nth-of-type(3) { @include scienceBubble(0.15, 1.595, .075, 0.7s, $scaleDefault); }
    }
    
    // scaled sizes based on em font-size
    @include emScale($scaleDefault);
    &.small { 
        @include emScale($scaleSmall); 
        
        i.bubble {
            &:nth-of-type(1) { @include scienceBubble(0.75, 1.9, .005, 0.7s, $scaleSmall); }
            &:nth-of-type(2) { @include scienceBubble(0.4, 2.3, .04, 0.8s, $scaleSmall); }
            &:nth-of-type(3) { @include scienceBubble(0.15, 1.7, .055, 0.7s, $scaleSmall); }
        }
    }
    
    &.medium { 
        @include emScale($scaleMedium); 
        
        i.bubble {
            &:nth-of-type(1) { @include scienceBubble(0.85, 2.15, .085, 0.7s, $scaleMedium); }
            &:nth-of-type(2) { @include scienceBubble(0.35, 2.2, .14, 0.8s, $scaleMedium); }
            &:nth-of-type(3) { @include scienceBubble(0.05, 2.045, .075, 0.7s, $scaleMedium); }
        }
    }
    
    i {
        transition: all 300ms cubic-bezier(.2,0,.7,1);
    }
    
    // animation styles for the hero icon's...icon
    // notice the omission of the animation name so the animation won't play
    // when not being hovered
    i.main{
        animation-duration: 0.75s; 
        animation-iteration-count: 1;
        animation-timing-function: linear;
        animation-name: none; 
    }
    
    i.steam {
        position: absolute;
        animation-duration: 2s; 
        animation-iteration-count: infinite;
        animation-timing-function: linear;
        animation-name: none;
        font-size: 0.5em;
        top: 0.3em;
        left: 1.5em;
    }
    
    .science-bubbles,
    .cup-steam {
        position: absolute;
        width: 100%;
        height: 100%;
        top: 0;
        left: 0;
        
        i {
            position: absolute;
            opacity: 0;
        }
    }
    
    
    
    &:hover {
        //border-width: 0;
        box-shadow: 0 0 1px 15px rgba(#6B0504, 1),
                    0 0 1px 30px rgba(#2D0605, 0.8),
                    0 0 100px 45px rgba(#A4031F, 0.3);
        
        // here is where we set the animation name, causing the animation to play on hover
        i:not(.bubble) {
            animation-name: scaleUpAndDown;
        }
        
        // center spin hover affect
        &.bolt-strike {
            overflow: hidden;
            
            i.main {
                transform-origin: 50% 100%;
                animation-name: boltStrike;
                position: absolute;
                top: 0.45em;
                left: 0.7em;
            }
            
        }
        
        // center spin hover affect
        &.center-spin {
            
            i.main {
                transform-origin: 50% 100%;
                animation-name: spinAroundToNeutral;
                position: absolute;
                left: 0.4em;
                top: 0.5em;
            }
            
        }
        
        &.change-spock {
            
            i.main {
                animation-name: none;
                &::before { content: "\f259"; }
            }
        }
        
        &.bomb-boom {
            i.main {
                animation-duration: 0.8s; 
                transform-origin: 50% 50%;
                animation-name: bombBoom;
            }
        }
        
        &.gavel-strike {
            i.main {
                animation-duration: 0.8s; 
                transform-origin: 50% 50%;
                animation-name: gavelStrike;
            }
        }
        
        &.rocket-flight {
            
            i.main {
                animation-duration: 1s; 
                transform-origin: 0% 50%;
                animation-name: rocketFlight;
                position: absolute;
                left: 0.49em;
                top: 0.45em;
            }
        }
        
        &.science-shake {
            
            i.main {
                animation-duration: 1.3s; 
                transform-origin: 50% 10%;
                animation-name: scienceShake;
                position: absolute;
                left: 0.49em;
                top: 0.45em;
            }
            
            i.bubble {
                animation-name: bubbleRise;
            }
        }
        
        &.punch {
            
            i.main {
                position: absolute;
                left: 0.525em;
                top: 0.45em;
                animation-duration: 1s;
                animation-name: punchUp;
            }
        }
        
        &.coffee-cup {
            
            i.main {
                animation-name: none;
            }
            
            i.steam {
                animation-name: coffeeSteam;
                opacity: 1;
            }
        }
        
        &.brush-strokes {
            
            i.main {
                position: absolute;
                left: 0.45em;
                top: 0.45em;
                transform-origin: 50% 50%;
                animation-duration: 0.4s;
                animation-iteration-count: 2;
                animation-name: brushStrokes;
            }
        }
        
        &.drip {
            
            i.main {
                position: absolute;
                left: 0.66em;
                top: 0.45em;
                animation-duration: 1.4s;
                animation-name: drip;
            }
        }
        
        &.spin-forever {
            
            i.main {
                position: absolute;
                left: 0.45em;
                top: 0.45em;
                transform-origin: 50% 50%;
                animation-duration: 0.4s;
                animation-iteration-count: 2;
                animation-name: spinAround;
            }
        }
    }
    
    
    
    // color specify calls to our hero icon mixin
    &.red { @include heroIcon($heroBaseRed, $lightIconColor, 20%, 10%, 23%, 10%); }
    
    &.yellow { @include heroIcon($heroBaseYellow, $darkIconColor, 30%, 10%, 23%, 10%); }
    
    &.green { @include heroIcon($heroBaseGreen, $darkIconColor, 30%, 10%, 23%, 10%); }
    
    &.skyblue { @include heroIcon($heroBaseSkyBlue, $darkIconColor, 20%, 10%, 23%, 10%); }
    
    &.deeppurple { @include heroIcon($heroBaseDeepPurple, $lightIconColor, 20%, 10%, 23%, 10%); }
    
    &.huntergreen { @include heroIcon($heroBaseHunterGreen, $lightIconColor, 20%, 10%, 23%, 10%); }
    
    &.tan { @include heroIcon($heroBaseTan, $darkIconColor, 30%, 10%, 23%, 10%); }
    
    &.pink { @include heroIcon($heroBasePink, $lightIconColor, 20%, 10%, 23%, 10%); }
    
    &.lavendar { @include heroIcon($heroBaseLavendar, $lightIconColor, 30%, 10%, 23%, 10%); }
    
    &.teal { @include heroIcon($heroBaseTeal, $lightIconColor, 20%, 10%, 23%, 10%); }
    
    &.orange { @include heroIcon($heroBaseOrange, $lightIconColor, 20%, 10%, 23%, 10%); }
    
    &.melon { @include heroIcon($heroBaseMelon, $lightIconColor, 20%, 10%, 23%, 10%); }
}

              
            
!

JS

              
                
              
            
!
999px

Console