cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

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.

Quick-add: + add another resource

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.

Quick-add: + add another resource

Code Indentation

     

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.

            
              <!-- http://callmenick.com/post/simple-responsive-tabs-javascript-css -->
<nav class="nav nav-group">
  <h1>Jasper Morrison</h1>  
  <a class="menu-toggle" href="#">Menu</a></li>
    </ul>
</nav><!--end .nav-->

<nav class="full-nav">
<div id="tabs" class="c-tabs no-js">  
  <div class="c-tabs-nav">
    <a href="#" class="c-tabs-nav__link is-active">Projects</a>
    <a href="#" class="c-tabs-nav__link">Exhibitions</a>
    <a href="#" class="c-tabs-nav__link">Publications</a>
    <a href="#" class="c-tabs-nav__link">Studio</a>
    <a href="#" class="c-tabs-nav__link">Shop</a>
    <a href="#" class="c-tabs-nav__link">Search</a>
  </div>
  <div class="c-tab is-active">
    <div class="c-tab__content">
      <h2 class="c-tab-title">Tab 1 list</h2>
      <ul class="c-tab__list">
        <li><a href="">Tableware</a></li>
        <li><a href="">Kitchen</a></li>
        <li><a href="">Chairs</a></li>
        <li><a href="">Sofas</a></li>
        <li><a href="">Tables</a></li>
        <li><a href="">Storage</a></li>
        <li><a href="">Lighting</a></li>
        <li><a href="">Office</a></li>
        <li><a href="">Electricals</a></li>
        <li><a href="">Urban</a></li>
        <li><a href="">Architectural</a></li>
        <li><a href="">Accessories</a></li>
        <li><a href="">Editions</a></li>
      </ul>
    </div>
  </div>
  <div class="c-tab">
    <div class="c-tab__content">
      <h2 class="c-tab-title">Tab 1 list</h2>
      <ul class="c-tab__list">
        <li>2010 - 2019</li>
        <li>2000 - 2010</li>
        <li>1990 - 1999</li>
        <li>1980 - 1989</li>

      </ul>
    </div>
  </div>
  <div class="c-tab">
    <div class="c-tab__content">
      <h2 class="c-tab-title">Tab 3 list</h2>
      <ul class="c-tab__list">
        <li>Books</li>
        <li>Essays</li>
        <li>Articles</li>
        <li>Interviews</li>
      </ul>
    </div>
  </div>
  <div class="c-tab">
    <div class="c-tab__content">
      <h2 class="c-tab-title">Tab 4 list</h2>
      <ul class="c-tab__list">
        <li>Office for Design</li>
        <li>Biography</li>
        <li>Credits and Links</li>
      </ul>
    </div>
  </div>
</div>
<form class="c-search" action="">
  <input type="text" placeholder="Search" />
  <button class="c-search__submit">Go</button>
</form>
</nav>
<main class="c-main-content">
  <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Obcaecati, unde earum ad, aliquid quisquam ipsa labore id animi dolorem qui ipsum quo nobis omnis vero aut porro ipsam, cumque mollitia!</p>
</main>
            
          
!
            
              /* apply a natural box layout model to all elements, but allowing components to change */
html {
  box-sizing: border-box;
}
*, *:before, *:after {
  box-sizing: inherit;
}

$grey: rgb(157, 146, 130);
$text-color: black;

body {
  color: $grey;
}

.c-tabs {
  padding-top: 1em;
  display: flex;
  align-items: stretch;
  -webkit-transition: height 1s;
          transition: height 1s;
  
  a {
      color: $grey;
      text-decoration: none;
    
      &:hover{
        color: $text-color;
      }
    }
}

.c-tabs-nav {
  display: -webkit-box;
  display: -webkit-flex;
  display: -ms-flexbox;
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  list-style: none;
  width: 50%;
  border-right: solid 1px $grey;
  margin: 0;
  padding-top: 0 1em;
}

.c-tabs-nav__link {
  -webkit-box-flex: 1;
  -webkit-flex: 1;
      -ms-flex: 1;
          flex: 1;
  flex-basis: 100%;
  text-align: right;
  margin-bottom: 0.25em;
  padding-right: 1em;
  -webkit-transition: color 0.3s;
          transition: color 0.3s;
}

.c-tabs-nav__link:last-child {
  margin-right: 0;
  background: red;
}

.c-tabs-nav__link:hover {
  color: $text-color;
}

.c-tabs-nav__link.is-active {
  color: $text-color;
}

.c-tabs-nav__link i,
.c-tabs-nav__link span {
  margin: 0;
  padding: 0;
  line-height: 1;
}

.c-tabs-nav__link i {
  font-size: 18px;
}

.c-tabs-nav__link span {
  display: none;
  font-size: 18px;
}

.c-search {
  margin: 1em;
  display: flex;
  
    input {
       flex-basis: 100%;
      -webkit-transition: width 0.3s;
              transition: width 0.3s;
    }
  
  .c-search__submit {
    width: 2.7em;
  }
}

@media all and (min-width: 720px) {
  .c-tabs-nav__link i {
    margin-bottom: 12px;
    font-size: 22px;
  }
  .c-tabs-nav__link span {
    display: block;
  }
}

/**
 * Tab
 */
.c-tab {
  display: none;
  width: 50%;
}

.c-tab.is-active {
  display: block;
}

.c-tab__content {
  padding: 0 1em;
  ul {
    list-style: none;
    margin: 0;
    padding: 0;
  }
  li{
    margin-bottom: 0.25em;
  }
}

/**
 * Tabs no-js fallback
 */
.c-tabs.no-js {
  display: flex;
  flex-wrap: wrap;
}

.c-tabs.no-js .c-tabs-nav {
  display: none;
}

.c-tabs .c-tab-title {
  display: none;
}

.c-tabs.no-js .c-tab-title {
  display: block;
}

.c-tabs.no-js .c-tab__list {
  display: flex;
  flex-wrap: wrap;
}

.c-tabs.no-js .c-tab {
  display: block;
  flex-basis: 100%;
  border-bottom: solid 1px;
}

.c-tabs.no-js .c-tab:last-child {
  margin-bottom: 0;
}

.c-main-content {
  color: $text-color;
  padding: 0 1em;
  width: 100%;
  height: 500px;
}

.nav-group {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 1em;
  border-bottom: solid 1px $grey;
  
  h1 {
    font-size: 1em;
  }
  
  .menu-toggle {
    text-decoration: none;
    color: $grey;
  }
}

.full-nav {
  //display: none;
  max-height: 0;
  overflow: hidden;
  
  -webkit-transition: max-height 0.2s;
          transition: max-height 0.2s;
}

.full-nav.is-active {
  //display: block;
  max-height: 1000px;
}
            
          
!
            
              (function() {

  'use strict';

  /**
   * tabs
   *
   * @description The Tabs component.
   * @param {Object} options The options hash
   */
  var tabs = function(options) {

    var el = document.querySelector(options.el);
    var tabNavigationLinks = el.querySelectorAll(options.tabNavigationLinks);
    var tabContentContainers = el.querySelectorAll(options.tabContentContainers);
    var activeIndex = 0;
    var initCalled = false;

    /**
     * init
     *
     * @description Initializes the component by removing the no-js class from
     *   the component, and attaching event listeners to each of the nav items.
     *   Returns nothing.
     */
    var init = function() {
      if (!initCalled) {
        initCalled = true;
        el.classList.remove('no-js');

        for (var i = 0; i < tabNavigationLinks.length; i++) {
          var link = tabNavigationLinks[i];
          handleClick(link, i);
        }
      }
    };

    /**
     * handleClick
     *
     * @description Handles click event listeners on each of the links in the
     *   tab navigation. Returns nothing.
     * @param {HTMLElement} link The link to listen for events on
     * @param {Number} index The index of that link
     */
    var handleClick = function(link, index) {
      link.addEventListener('click', function(e) {
        e.preventDefault();
        goToTab(index);
      });
    };

    /**
     * goToTab
     *
     * @description Goes to a specific tab based on index. Returns nothing.
     * @param {Number} index The index of the tab to go to
     */
    var goToTab = function(index) {
      if (index !== activeIndex && index >= 0 && index <= tabNavigationLinks.length) {
        tabNavigationLinks[activeIndex].classList.remove('is-active');
        tabNavigationLinks[index].classList.add('is-active');
        tabContentContainers[activeIndex].classList.remove('is-active');
        tabContentContainers[index].classList.add('is-active');
        activeIndex = index;
      }
    };

    /**
     * Returns init and goToTab
     */
    return {
      init: init,
      goToTab: goToTab
    };

  };

  /**
   * Attach to global namespace
   */
  window.tabs = tabs;

})();

var myTabs = tabs({
    el: '#tabs',
    tabNavigationLinks: '.c-tabs-nav__link',
    tabContentContainers: '.c-tab'
  });

myTabs.init();

$(document).ready(function() {

   $('body').addClass('js');

   var $topNavToggle = $('.menu-toggle'),
       $fullNav = $('.full-nav');

     // When clicking on toggle
     $topNavToggle.click(function() {

        $fullNav.toggleClass('is-active');
        return false;

     });

 });
            
          
!
999px
Loading ..................

Console