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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ 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

              
                <div class="main">
  <ul class="tab-menu">
    <li class="tab tab1">TAB1</li>
    <li class="tab tab2">TAB2</li>
    <li class="tab tab3">TAB3</li>
  </ul>
  <ul class="content-box">
    <li class="content content1 show">CONTENT1</li>
    <li class="content content2">CONTENT2</li>
    <li class="content content3">CONTENT3</li>
  </ul>
</div>
              
            
!

CSS

              
                body {
  color: #333;
}

ul,
li {
  margin: 0;
  padding: 0;
}

ul {
  list-style: none;
}

.main {
  margin: auto;
  width: 60%;
}

.tab-menu {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
}
.tab-menu li {
  width: 33.33%;
  text-align: center;
  padding: 10px 0;
  cursor: pointer;
  font-weight: 700;
}

.tab1,
.content1 {
  background: blue;
}

.tab2,
.content2 {
  background: yellow;
}

.tab3,
.content3 {
  background: red;
}

.content {
  height: 300px;
  text-align: center;
  line-height: 300px;
  font-weight: 700;
  display: none;
}

.content.show {
  display: block;
}
              
            
!

JS

              
                $(function() {
  
  //いずれかのタブをクリックしたら処理が発動する
  $('.tab').click(function() {
    
  //現在.contentに付いているクラスは一旦全部取り除く
  $('.content').removeClass('show');
    
  //クリックしたタブの順番を取得
  var i = $(this).index();
    
  //タブの順番と同じコンテンツに.showを付けてコンテンツを表示する
  $('.content').eq(i).addClass('show');

  });
});
              
            
!
999px

Console