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

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

              
                <dl class="tabs">
  <dt class="tabs__item tabs__item--active">Tab 1</dt>
  <dd class="tabs__body">
    <div class="tabs__content">This is a semantic tab box with some fancy animations.</div>
  </dd>
  
  <dt class="tabs__item">Tab 2</dt>
  <dd class="tabs__body">
    <div class="tabs__content">It's super exciting.</div>
  </dd>
  
  <dt class="tabs__item">Tab 3</dt>
  <dd class="tabs__body">
    <div class="tabs__content"><p>It relies on jQuery, and it can only be a fixed height due to the absolute positioning, but whatever. That's the price you're paying for sensible markup I guess.<p>Check out my multiple paragraphs.</div>
  </dd>
</dl>

<dl class="tabs tabs--vertical">
  <dt class="tabs__item tabs__item--active">Tab 1</dt>
  <dd class="tabs__body">
    <div class="tabs__content">This is the same thing, but vertical.</div>
  </dd>
  
  <dt class="tabs__item">Tab 2</dt>
  <dd class="tabs__body">
    <div class="tabs__content">Same caveats as before, but I'll be damned if it isn't pretty.</div>
  </dd>
  
  <dt class="tabs__item">Tab 3</dt>
  <dd class="tabs__body">
    <div class="tabs__content">Why are you reading these anyway</div>
  </dd>
</dl>
              
            
!

CSS

              
                @import url(https://fonts.googleapis.com/css?family=Roboto:700,400,300);

$spacing: 24px;

$gray-1: #ecf0f1;
$gray-2: darken($gray-1, 5%);
$gray-3: darken($gray-2, 5%);
$gray-4: darken($gray-3, 5%);
$gray-5: darken($gray-4, 5%);
$gray-6: darken($gray-5, 5%);
$gray-7: darken($gray-6, 5%);
$gray-8: darken($gray-7, 5%);
$gray-9: darken($gray-8, 5%);
$gray-10: darken($gray-9, 5%);

$violet: #9b59b6;


body {
  font-size: 18px;
  font-weight: 300;
  font-family: "Roboto", sans-serif;
  padding: 50px;
  width: 600px;
  margin: 0 auto;
}


p {
  margin-top: 0;
  margin-bottom: $spacing;
}


.tabs {
  position: relative;
  margin-bottom: $spacing;
  height: 300px
}

.tabs__item {
  position: relative;
  display: inline-block;
  z-index: 20;
  line-height: 2.5;
  margin-right: -0.28em;
  padding-left: $spacing / 2;
  padding-right: $spacing / 2;
  color: white;
  box-shadow: inset 0 50px $violet;
  background-color: $gray-1;
  transition: box-shadow 0.35s ease-out, color 0.4s ease-out;
  cursor: pointer;
  &:hover {
    box-shadow: inset 0 50px lighten($violet, 8%);
  }
  &:first-child {
   margin-left: $spacing / 2;
  }
}
.tabs__item--active {
  color: $violet;
  box-shadow: inset 0 0 $violet !important;
  & + .tabs__body {
    z-index: 10;
  }
}

.tabs__body {
  position: absolute;
  overflow: hidden;
  left: 0;
  right: 0;
  height: 200px;
  margin-left: 0;
  padding: $spacing;
  border-radius: 4px;
  border-bottom: 2px solid $gray-3;
  background-color: $gray-1;
  transition: all 0.25s;
}

.tabs__content {
//  height: 200px;
  opacity: 1;
  transition: all 0.15s ease-out;
}
.tabs__content--hidden {
  opacity: 0;
  transform: translate(0, $spacing / 3);
}


// Vertical
.tabs--vertical {
  .tabs__item {
    display: block;
    width: 150px;
    margin-left: 0;
    box-shadow: inset 150px 0 0 $violet;
    &:hover {
      box-shadow: inset 150px 0 0 lighten($violet, 8%);
    }
  }
  .tabs__body {
    top: 0;
    left: 150px;
  }
  .tabs__content--hidden {
    transform: translate($spacing / 3, 0);
  }
}
              
            
!

JS

              
                $(".tabs").each(function() {
  var $tabs =       $(this),
      $tabItem =    $tabs.children(".tabs__item"),
      $tabBody =    $tabs.children(".tabs__body"),
      $tabContent = $tabBody.children(".tabs__content");
  
  $tabItem.click(function() {
    var $currentTab = $(this);
    
    $tabContent.addClass("tabs__content--hidden");
    $tabItem.removeClass("tabs__item--active");

    setTimeout(function() {
      $currentTab.addClass("tabs__item--active");
     
    }, 200);
      
    setTimeout(function() {   
       $tabContent.removeClass("tabs__content--hidden");
    }, 500); 
    
    
   
 

  });
});
              
            
!
999px

Console