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

              
                <!DOCTYPE html>
<html>
    <head>
        <!--[if lt IE 9]>
            <script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/r29/html5.min.js"></script>
            <script src="//cdnjs.cloudflare.com/ajax/libs/respond.js/1.4.2/respond.js"></script>
        <![endif]-->
        <title>Tabs to Dropdown</title>
        <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
        <link rel="icon" href="favicon.ico" type="image/x-icon">
        <link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/normalize/3.0.1/normalize.min.css">
        <link rel="stylesheet" href="//fonts.googleapis.com/css?family=Roboto:500">
        <link rel="stylesheet" href="//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css">
        <link rel="stylesheet" href="css/page.css">
        <link rel="stylesheet" href="css/tabs-to-dropdown.css">
    </head>
    <body>
        <header class="tabs-to-dropdown">
            <nav class="tab-bar">
                <ul>
                    <li class="active"><a href="#"><span class="fa fa-home"></span></a></li>
                    <li><a href="#0">Products</a></li>
                    <li><a href="#0">Library</a></li>
                    <li><a href="#0">Strategy for succes!</a></li>
                    <li><a href="#0">Case studies</a></li>
                    <li><a href="#0">Join us</a></li>
                    <li><a href="#0">Contact</a></li>
                </ul>
            </nav>
            <div class="dropdown">
                <button class="dropdown-toggle">...<span class="fa fa-angle-down"></span></button>
                <ul></ul>
            </div>
        </header>

        <main>
            <h2><small>Fully responsive</small> Tabs to Dropdown!</h2>
        </main>

        <!-- Scripts -->
        <script src="//code.jquery.com/jquery-1.11.0.min.js"></script>
        <script src="js/tabs-to-dropdown.js"></script>
    </body>
</html>

              
            
!

CSS

              
                /* General */
html,body { min-height:100%; }
body {
    background:url(../img/nice-by-night.jpg) no-repeat center / cover;
    font-family:Roboto, Arial, sans-serif;
}

/* Main */
main>h2 {
    font-size:60px;
    background:rgba(19, 32, 45,.4);
    position:absolute;
    bottom:10%;right:5%;
    color:#fff;
    padding:25px;margin:0;
    text-align:right;
}
main>h2>small{
    font-size:30px;
    display:block;
    color:rgba(25, 189, 155,1);
    text-transform:uppercase;
}

/* Media Queries */
@media all and (max-width:699px), all and (max-height:340px) {
    main>h2 {
        padding:10px;
        right:10px;
        font-size:35px;
        line-height:35px;
    }
    main>h2>small{
        font-size:20px;
        line-height:20px;
    }
}

/* Transitions */
main>h2,
main>h2>small {
    -webkit-transition:all .2s ease;
    -moz-transition:all .2s ease;
    -ms-transition:all .2s ease;
    -o-transition:all .2s ease;
    transition:all .2s ease;
}

.tabs-to-dropdown a,
.tabs-to-dropdown button,
.tabs-to-dropdown input[type=button] {
    text-decoration:none;
    -webkit-tap-highlight-color:transparent;
    tap-highlight-color:transparent;
    -ms-touch-action:manipulation;
    touch-action:manipulation;
}

/* Tabs bar */
.tabs-to-dropdown {
    background:rgb(45, 62, 80);
    position:relative;
    z-index:9999;
}
.tabs-to-dropdown::after {
    display:block;
    content:"";
    width:76px;
    position:absolute;
    right:0;bottom:0;top:0;
    background:-moz-linear-gradient(left, rgba(45,62,80,0) 0%, rgba(45,62,80,1) 28%, rgba(45,62,80,1) 100%);
    background:-webkit-gradient(linear, left top, right top, color-stop(0%,rgba(45,62,80,0)), color-stop(28%,rgba(45,62,80,1)), color-stop(100%,rgba(45,62,80,1)));
    background:-webkit-linear-gradient(left, rgba(45,62,80,0) 0%,rgba(45,62,80,1) 28%,rgba(45,62,80,1) 100%);
    background:-o-linear-gradient(left, rgba(45,62,80,0) 0%,rgba(45,62,80,1) 28%,rgba(45,62,80,1) 100%);
    background:-ms-linear-gradient(left, rgba(45,62,80,0) 0%,rgba(45,62,80,1) 28%,rgba(45,62,80,1) 100%);
    background:linear-gradient(to right, rgba(45,62,80,0) 0%,rgba(45,62,80,1) 28%,rgba(45,62,80,1) 100%);
}
.tabs-to-dropdown>.tab-bar {
    overflow:hidden;
    margin-right:46px;
    position:relative;
}
.tabs-to-dropdown>.tab-bar>ul {
    width:99999px;
    margin:0;padding:0;
    list-style:none;
}
.tabs-to-dropdown>.tab-bar>ul::after{
    display:table;
    content:"";
    clear:both;
}
.tabs-to-dropdown>.tab-bar>ul>li {
    display:inline-block;
    float:left;
    opacity:1;visibility:visible;
}
.tabs-to-dropdown>.tab-bar>ul>li.ttd-hide{
    opacity:0;visibility:hidden;
}
.tabs-to-dropdown>.tab-bar>ul>li>a {
    display:inline-block;
    color:rgba(255,255,255,1);
    font-size:16px;
    text-transform:uppercase;
    padding:0 20px;
    line-height:90px;
}
.tabs-to-dropdown>.tab-bar>ul>li>a:hover { color:rgb(25, 189, 155); }
.tabs-to-dropdown>.tab-bar>ul>li>a:active { color:rgba(25, 189, 155,.65); }

/* Home button */
.tabs-to-dropdown>.tab-bar>ul>li>a>.fa {
    font-size:34px;
    padding:0 9px;
}

/* Acctive */
.tabs-to-dropdown>.tab-bar>ul>li.active { background:rgb(25, 189, 155); }
.tabs-to-dropdown>.tab-bar>ul>li.active:hover { opacity:.85; }
.tabs-to-dropdown>.tab-bar>ul>li.active:active { opacity:.7; }
.tabs-to-dropdown>.tab-bar>ul>li.active>a { color:rgba(255,255,255,1); }

/* dropdown */
.tabs-to-dropdown>.dropdown>button.dropdown-toggle {
    border:0;outline:0;box-shadow:none;
    display:inline-block;
    line-height:90px;
    background:none;
    color:rgba(255,255,255,1);
    font-size:25px;
    padding:0 20px; margin:0;
    position:absolute;
    top:0;right:0;
    z-index:2;
    cursor:pointer!important;
    opacity:0;visibility:hidden;
}
.tabs-to-dropdown>.dropdown.ttd-show>button.dropdown-toggle { opacity:1;visibility:visible; }
.tabs-to-dropdown>.dropdown>button.dropdown-toggle:hover { color:rgb(25, 189, 155); }

.tabs-to-dropdown>.dropdown>button.dropdown-toggle:active,
.tabs-to-dropdown>.dropdown.ttd-open>button.dropdown-toggle { color:rgba(25, 189, 155,.65); }

.tabs-to-dropdown>.dropdown>ul {
    list-style:none;
    margin:0;padding:0;
    position:absolute;
    z-index:1;
    top:60px;right:0;
    max-width:300px;
    background:rgba(45, 62, 80,.8);
    opacity:0;visibility:hidden;
}
.tabs-to-dropdown>.dropdown.ttd-open>ul {
    opacity:1;visibility:visible;
    top:90px;
}
.tabs-to-dropdown>.dropdown>ul>li {
    margin:0;padding:0;
    opacity:0;visibility:hidden;
    max-height:0;
}
.tabs-to-dropdown>.dropdown.ttd-open>ul>li.ttd-show{
    opacity:1;visibility:visible;
    max-height:50px;
}
.tabs-to-dropdown>.dropdown>ul>li>a {
    display:block;
    white-space:nowrap;
    overflow:hidden;
    text-overflow:ellipsis;
    color:rgba(255,255,255,1);
    padding:15px 15px;
    text-transform:uppercase;
    font-size:14px;
    line-height:18px;
}
.tabs-to-dropdown>.dropdown.ttd-open>ul>li>a:hover { background:rgb(25, 189, 155); }
.tabs-to-dropdown>.dropdown.ttd-open>ul>li>a:active { background:rgba(25, 189, 155,.65);}

/* Media Queries */
@media all and (max-width:699px) {
    /* Tabs bar */
    .tabs-to-dropdown>.tab-bar { margin-right:37px; }
    .tabs-to-dropdown::after { width:55px; }
    .tabs-to-dropdown>.tab-bar>ul>li>a {
        font-size:14px;
        padding:0 15px;
        line-height:50px;
    }
    .tabs-to-dropdown>.tab-bar>ul>li>a>.fa {
        font-size:24px;
        padding:0;
    }
    /* Dropdown */
    .tabs-to-dropdown>.dropdown>button.dropdown-toggle {
        line-height:50px;
        font-size:21px;
        padding:0 10px;
    }
    .tabs-to-dropdown>.dropdown>ul { top:30px }
    .tabs-to-dropdown>.dropdown.ttd-open>ul { top:50px; }
    .tabs-to-dropdown>.dropdown>ul>li>a {
        padding:10px;
        font-size:12px;
        line-height:16px;
    }
}

/* Transition */
.tabs-to-dropdown>.tab-bar>ul>li,
.tabs-to-dropdown>.tab-bar>ul>li>a,
.tabs-to-dropdown>.tab-bar>ul>li>a>.fa,
.tabs-to-dropdown>.dropdown>button.dropdown-toggle,
.tabs-to-dropdown>.dropdown,
.tabs-to-dropdown>.dropdown>ul,
.tabs-to-dropdown>.dropdown>ul>li,
.tabs-to-dropdown>.dropdown>ul>li>a {
    -webkit-transition:all .2s ease;
    -moz-transition:all .2s ease;
    -ms-transition:all .2s ease;
    -o-transition:all .2s ease;
    transition:all .2s ease;
}
.tabs-to-dropdown>.tab-bar>ul>li.active:active,
.tabs-to-dropdown a:active,
.tabs-to-dropdown button:active,
.tabs-to-dropdown input[type=button] {
    -webkit-transition:none!important;
    -moz-transition:none!important;
    -ms-transition:none!important;
    -o-transition:all 0 ease!important;
    transition:none!important;
}


              
            
!

JS

              
                $(function() {
    $(".tabs-to-dropdown").each(function() {
        var resizeTimeout   = 20;

        var tabBar          = $(this).children(".tab-bar");
        var tabList         = tabBar.children("ul");
        var tabListItem     = tabList.children("li");

        var dropdown        = $(this).children(".dropdown");
        var dropdownToggle  = dropdown.children(".dropdown-toggle");
        var dropdownList    = dropdown.children("ul");

        var clickHandler = ("ontouchstart" in document.documentElement ? "touchstart": "click");

        var tabsToDropdown  = function() {
            var tabBarWidth = tabBar.width();
            tabListItem.each(function(index) {
                var dropdownListItem  = dropdownList.children("li").eq(index);
                var tabListItemOffset = $(this).position().left + $(this).outerWidth();

                if (tabListItemOffset >= tabBarWidth) {
                    $(this).addClass("ttd-hide"); dropdownListItem.addClass("ttd-show");
                } else {
                    $(this).removeClass("ttd-hide"); dropdownListItem.removeClass("ttd-show");
                }
            });

            tabList.children(".ttd-hide").length > 0 ? dropdown.addClass("ttd-show"): dropdown.removeClass("ttd-show");
        };

        tabListItem.clone().appendTo(dropdownList);

        tabsToDropdown();
        $(window).bind("resize", function(){
            if(typeof sizeWait != "undefined") { clearTimeout(sizeWait); }
            sizeWait = setTimeout(function(){
                tabsToDropdown();
            },resizeTimeout);
        });

        dropdown.bind(clickHandler, function(e) { e.stopPropagation(); });
        $(document).bind(clickHandler, function() { dropdown.removeClass("ttd-open"); });
        dropdownToggle.bind(clickHandler, function(e) { dropdown.toggleClass("ttd-open"); e.stopPropagation(); });
    });
});

              
            
!
999px

Console