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

              
                <select multiple data-placeholder="Add tools">
    <option>Sketch</option>
    <option selected>Framer X</option>
    <option>Photoshop</option>
    <option>Principle</option>
    <option>Invision</option>
</select>

<!-- dribbble -->
<a class="dribbble" href="https://dribbble.com/shots/5112850-Multiple-select-animation-field" target="_blank"><img src="https://cdn.dribbble.com/assets/dribbble-ball-1col-dnld-e29e0436f93d2f9c430fde5f3da66f94493fdca66351408ab0f96e2ec518ab17.png" alt=""></a>
              
            
!

CSS

              
                $textColor: #1E2330;
$primary: #4D18FF;

.selectMultiple {
    width: 240px;
    position: relative;
    select {
        display: none;
    }
    & > div {
        position: relative;
        z-index: 2;
        padding: 8px 12px 2px 12px;
        border-radius: 8px;
        background: #fff;
        font-size: 14px;
        min-height: 44px;
        box-shadow: 0 4px 16px 0 rgba(#162A5A, .12);
        transition: box-shadow .3s ease;
        &:hover {
            box-shadow: 0 4px 24px -1px rgba(#162A5A, .16);
        }
        .arrow {
            right: 1px;
            top: 0;
            bottom: 0;
            cursor: pointer;
            width: 28px;
            position: absolute;
            &:before,
            &:after {
                content: '';
                position: absolute;
                display: block;
                width: 2px;
                height: 8px;
                border-bottom: 8px solid #99A3BA;
                top: 43%;
                transition: all .3s ease;
            }
            &:before {
                right: 12px;
                transform: rotate(-130deg);
            }
            &:after {
                left: 9px;
                transform: rotate(130deg);
            }
        }
        span {
            color: #99A3BA;
            display: block;
            position: absolute;
            left: 12px;
            cursor: pointer;
            top: 8px;
            line-height: 28px;
            transition: all .3s ease;
            &.hide {
                opacity: 0;
                visibility: hidden;
                transform: translate(-4px, 0);
            }
        }
        a {
            position: relative;
            padding: 0 24px 6px 8px;
            line-height: 28px;
            color: $textColor;
            display: inline-block;
            vertical-align: top;
            margin: 0 6px 0 0;
            em {
                font-style: normal;
                display: block;
                white-space: nowrap;
            }
            &:before {
                content: '';
                left: 0;
                top: 0;
                bottom: 6px;
                width: 100%;
                position: absolute;
                display: block;
                background: rgba(#E4ECFA, .7);
                z-index: -1;
                border-radius: 4px;
            }
            i {
                cursor: pointer;
                position: absolute;
                top: 0;
                right: 0;
                width: 24px;
                height: 28px;
                display: block;
                &:before,
                &:after {
                    content: '';
                    display: block;
                    width: 2px;
                    height: 10px;
                    position: absolute;
                    left: 50%;
                    top: 50%;
                    background: $primary;
                    border-radius: 1px;
                }
                &:before {
                    transform: translate(-50%, -50%) rotate(45deg);
                }
                &:after {
                    transform: translate(-50%, -50%) rotate(-45deg);
                }
            }
            &.notShown {
                opacity: 0;
                transition: opacity .3s ease;
                &:before {
                    width: 28px;
                    transition: width .45s cubic-bezier(.87,-.41,.19,1.44) .2s;
                }
                i {
                    opacity: 0;
                    transition: all .3s ease .3s;
                }
                em {
                    opacity: 0;
                    transform: translate(-6px, 0);
                    transition: all .4s ease .3s;
                }
                &.shown {
                    opacity: 1;
                    &:before {
                        width: 100%;
                    }
                    i {
                        opacity: 1;
                    }
                    em {
                        opacity: 1;
                        transform: translate(0, 0);
                    }
                }
            }
            &.remove {
                &:before {
                    width: 28px;
                    transition: width .4s cubic-bezier(.87,-.41,.19,1.44) 0s;
                }
                i {
                    opacity: 0;
                    transition: all .3s ease 0s;
                }
                em {
                    opacity: 0;
                    transform: translate(-12px, 0);
                    transition: all .4s ease 0s;
                }
                &.disappear {
                    opacity: 0;
                    transition: opacity .5s ease 0s;
                }
            }
        }
    }
    & > ul {
        margin: 0;
        padding: 0;
        list-style: none;
        font-size: 16px;
        z-index: 1;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        visibility: hidden;
        opacity: 0;
        border-radius: 8px;
        transform: translate(0, 20px) scale(.8);
        transform-origin: 0 0;
        filter: drop-shadow(0 12px 20px rgba(#162A5A, .08));
        transition: all .4s ease, transform .4s cubic-bezier(.87,-.41,.19,1.44), filter .3s ease .2s;
        li {
            color: $textColor;
            background: #fff;
            padding: 12px 16px;
            cursor: pointer;
            overflow: hidden;
            position: relative;
            transition: background .3s ease, color .3s ease, transform .3s ease .3s, opacity .5s ease .3s, border-radius .3s ease .3s;
            &:first-child {
                border-radius: 8px 8px 0 0;
                &:last-child {
                    border-radius: 8px;
                }
            }
            &:last-child {
                border-radius: 0 0 8px 8px;
                &:first-child {
                    border-radius: 8px;
                }
            }
            &:hover {
                background: $primary;
                color: #fff;
            }
            &:after {
                content: '';
                position: absolute;
                top: 50%;
                left: 50%;
                width: 6px;
                height: 6px;
                background: rgba(#000, .4);
                opacity: 0;
                border-radius: 100%;
                transform: scale(1, 1) translate(-50%, -50%);
                transform-origin: 50% 50%;
            }
            &.beforeRemove {
                border-radius: 0 0 8px 8px;
                &:first-child {
                    border-radius: 8px;
                }
            }
            &.afterRemove {
                border-radius: 8px 8px 0 0;
                &:last-child {
                    border-radius: 8px;
                }
            }
            &.remove {
                transform: scale(0);
                opacity: 0;
                &:after {
                    animation: ripple .4s ease-out;
                }
            }
            &.notShown {
                display: none;
                transform: scale(0);
                opacity: 0;
                transition: transform .35s ease, opacity .4s ease;
                &.show {
                    transform: scale(1);
                    opacity: 1;
                }
            }
        }
    }
    &.open {
        & > div {
            box-shadow: 0 4px 20px -1px rgba(#162A5A, .12);
            .arrow {
                &:before {
                    transform: rotate(-50deg);
                }
                &:after {
                    transform: rotate(50deg);
                }
            }
        }
        & > ul {
            transform: translate(0, 12px) scale(1);
            opacity: 1;
            visibility: visible;
            filter: drop-shadow(0 16px 24px rgba(#162A5A, .16));
        }
    }
}

@keyframes ripple {
    0% {
        transform: scale(0, 0);
        opacity: 1;
    }
    25% {
        transform: scale(30, 30);
        opacity: 1;
    }
    100% {
        opacity: 0;
        transform: scale(50, 50);
    }
}

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

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

// Center & dribbble
body {
    min-height: 100vh;
    font-family: Roboto, Arial;
    color: #ADAFB6;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #fff;
    .selectMultiple {
        margin-top: -12%;
    }
    .dribbble {
        position: fixed;
        display: block;
        right: 20px;
        bottom: 20px;
        opacity: .5;
        transition: all .4s ease;
        &:hover {
            opacity: 1;
        }
        img {
            display: block;
            height: 36px;
        }
    }
}
              
            
!

JS

              
                $(document).ready(function() {

    var select = $('select[multiple]');
    var options = select.find('option');

    var div = $('<div />').addClass('selectMultiple');
    var active = $('<div />');
    var list = $('<ul />');
    var placeholder = select.data('placeholder');

    var span = $('<span />').text(placeholder).appendTo(active);

    options.each(function() {
        var text = $(this).text();
        if($(this).is(':selected')) {
            active.append($('<a />').html('<em>' + text + '</em><i></i>'));
            span.addClass('hide');
        } else {
            list.append($('<li />').html(text));
        }
    });

    active.append($('<div />').addClass('arrow'));
    div.append(active).append(list);

    select.wrap(div);

    $(document).on('click', '.selectMultiple ul li', function(e) {
        var select = $(this).parent().parent();
        var li = $(this);
        if(!select.hasClass('clicked')) {
            select.addClass('clicked');
            li.prev().addClass('beforeRemove');
            li.next().addClass('afterRemove');
            li.addClass('remove');
            var a = $('<a />').addClass('notShown').html('<em>' + li.text() + '</em><i></i>').hide().appendTo(select.children('div'));
            a.slideDown(400, function() {
                setTimeout(function() {
                    a.addClass('shown');
                    select.children('div').children('span').addClass('hide');
                    select.find('option:contains(' + li.text() + ')').prop('selected', true);
                }, 500);
            });
            setTimeout(function() {
                if(li.prev().is(':last-child')) {
                    li.prev().removeClass('beforeRemove');
                }
                if(li.next().is(':first-child')) {
                    li.next().removeClass('afterRemove');
                }
                setTimeout(function() {
                    li.prev().removeClass('beforeRemove');
                    li.next().removeClass('afterRemove');
                }, 200);

                li.slideUp(400, function() {
                    li.remove();
                    select.removeClass('clicked');
                });
            }, 600);
        }
    });

    $(document).on('click', '.selectMultiple > div a', function(e) {
        var select = $(this).parent().parent();
        var self = $(this);
        self.removeClass().addClass('remove');
        select.addClass('open');
        setTimeout(function() {
            self.addClass('disappear');
            setTimeout(function() {
                self.animate({
                    width: 0,
                    height: 0,
                    padding: 0,
                    margin: 0
                }, 300, function() {
                    var li = $('<li />').text(self.children('em').text()).addClass('notShown').appendTo(select.find('ul'));
                    li.slideDown(400, function() {
                        li.addClass('show');
                        setTimeout(function() {
                            select.find('option:contains(' + self.children('em').text() + ')').prop('selected', false);
                            if(!select.find('option:selected').length) {
                                select.children('div').children('span').removeClass('hide');
                            }
                            li.removeClass();
                        }, 400);
                    });
                    self.remove();
                })
            }, 300);
        }, 400);
    });

    $(document).on('click', '.selectMultiple > div .arrow, .selectMultiple > div span', function(e) {
        $(this).parent().parent().toggleClass('open');
    });

});

              
            
!
999px

Console