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

Packages

Add Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import or require. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

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.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              <select data-menu="vertical">
    <option selected>iPhone</option>
    <option>Watch</option>
    <option>iPad</option>
    <option>Mac</option>
</select>

<select data-menu="horizontal">
    <option selected>iPhone</option>
    <option>Watch</option>
    <option>iPad</option>
    <option>Mac</option>
</select>

<!-- dribbble -->
<a class="dribbble" href="https://dribbble.com/shots/6948720-Menu-interaction" target="_blank"><img src="https://dribbble.com/assets/logo-small-2x-9fe74d2ad7b25fba0f50168523c15fda4c35534f9ea0b1011179275383035439.png" alt=""></a>
            
          
!
            
              .select-menu {
    --background: #fff;
    --text: #171C28;
    --icon: #3F4656;
    --shadow: rgba(18, 22, 33, .2);
    position: relative;
    select,
    button {
        font-family: 'Mukta Malar', Arial;
        font-weight: 500;
        font-size: 14px;
        line-height: 21px;
        margin: 0;
        border: 0;
        outline: 0;
        text-align: left;
        text-transform: none;
        -webkit-appearance: none;
    }
    select {
        pointer-events: none;
        user-select: none;
        opacity: 0;
        padding: 8px 36px 8px 10px;
        visibility: hidden;
    }
    button {
        position: absolute;
        left: 0;
        top: 0;
        right: 0;
        bottom: 0;
        padding: 0;
        width: 100%;
        display: block;
        cursor: pointer;
        overflow: hidden;
        border-radius: 6px;
        box-shadow: 0 4px 12px var(--shadow);
        color: var(--text);
        background: var(--background);
        div {
            position: relative;
            span {
                display: block;
                padding: 8px 32px 8px 10px;
                &.next {
                    position: absolute;
                    width: 100%;
                }
            }
        }
        em {
            --r: 45deg;
            display: block;
            position: absolute;
            right: 12px;
            top: 50%;
            width: 7px;
            height: 7px;
            margin-top: -4px;
            &:before {
                content: '';
                width: 7px;
                height: 7px;
                display: block;
                transform: rotate(var(--r)) scale(.75);
                border-right: 2px solid var(--icon);
                border-bottom: 2px solid var(--icon);
            }
        }
    }
    &.vertical {
        button {
            div {
                display: flex;
                span {
                    left: 0;
                    bottom: 100%;
                }
            }
        }
    }
    &.horizontal {
        button {
            div {
                display: flex;
                span {
                    right: 100%;
                    top: 0;
                }
            }
            em {
                --r: -45deg;
                margin-top: -3px;
            }
        }
    }
    &.change {
        button {
            animation: bounce-vertical .45s linear;
            div {
                animation: button-vertical .6s linear forwards .05s;
            }
            em {
                animation: arrow-vertical .45s linear;
            }
        }
        &.horizontal {
            button {
                animation-name: bounce-horizontal;
                div {
                    animation-name: button-horizontal;
                }
                em {
                    animation-name: arrow-horizontal;
                }
            }
        }
    }
}

@keyframes bounce-vertical {
    20% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(2px);
        box-shadow: 0 2px 8px var(--shadow);
    }
}

@keyframes bounce-horizontal {
    20% {
        transform: translateX(0);
    }
    50% {
        transform: translateX(2px);
        box-shadow: 0 8px 12px var(--shadow);
    }
}

@keyframes button-vertical {
    40% {
        transform: translateY(108%);
    }
    75% {
        transform: translateY(99%);
    }
    100% {
        transform: translateY(100%);
    }
}

@keyframes button-horizontal {
    40% {
        transform: translateX(104%);
    }
    75% {
        transform: translateX(99%);
    }
    100% {
        transform: translateX(100%);
    }
}

@keyframes arrow-vertical {
    20% {
        transform: translateY(var(--h));
        filter: blur(.5px);
        opacity: 1;
    }
    21% {
        transform: translateY(var(--h));
        opacity: 0;
    }
    22% {
        transform: translateY(calc(var(--h) * -1));
        opacity: 0;
    }
    23% {
        transform: translateY(calc(var(--h) * -1));
        opacity: 1;
    }
    50% {
        transform: translateY(4px);
        filter: blur(0);
    }
    100% {
        transform: translateY(0);
    }
}

@keyframes arrow-horizontal {
    20% {
        transform: translateX(var(--w));
        filter: blur(.5px);
        opacity: 1;
    }
    21% {
        transform: translateX(var(--w));
        opacity: 0;
    }
    22% {
        transform: translateX(calc(var(--w) * -1));
        opacity: 0;
    }
    23% {
        transform: translateX(calc(var(--w) * -1));
        opacity: 1;
    }
    50% {
        transform: translateX(4px);
        filter: blur(0);
    }
    100% {
        transform: translateX(0);
    }
}

html {
    box-sizing: border-box;
    -webkit-font-smoothing: antialiased;
}

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

// Center & dribbble
body {
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #275EFE;
    font-family: 'Mukta Malar', Arial;
    @media(max-width: 400px) {
        flex-direction: column;
    }
    .select-menu {
        margin: 20px;
    }
    .dribbble {
        position: fixed;
        display: block;
        right: 24px;
        bottom: 24px;
        img {
            display: block;
            width: 76px;
        }
    }
}
            
          
!
            
              $('select[data-menu]').each(function() {

    let select = $(this),
        type = select.data('menu'),
        menu = $('<div />').addClass('select-menu ' + type),
        button = $('<button />'),
        buttonDiv = $('<div />'),
        current = $('<span />').text(select.find('option:selected').text()).appendTo(buttonDiv),
        arrow = $('<em />').prependTo(button);
    
    button.css({
        '--h': select.outerHeight(),
        '--w': select.outerWidth()
    });

    select.wrap(menu);

    button.append(buttonDiv).insertAfter(select);

});

$(document).on('click', '.select-menu', function(e) {

    let menu = $(this),
        select = menu.children('select'),
        options = select.find('option'),
        active = select.find('option:selected'),
        button = menu.children('button'),
        buttonDiv = button.children('div'),
        current = buttonDiv.children('span');

    if(!menu.hasClass('change')) {

        let nextOption = options.eq(active.index() == options.length - 1 ? 0 : active.index() + 1),
            next = $('<span />').addClass('next').text(nextOption.text()).appendTo(buttonDiv);

        options.attr('selected', false);
        nextOption.attr('selected', true);

        menu.addClass('change');

        setTimeout(() => {

            next.removeClass('next');
            menu.removeClass('change');
            current.remove();

        }, 650);

    }

});

            
          
!
999px

Console