Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs 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 its URL and the proper URL extension.

+ 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

Auto Save

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

              
                <ul id="tabs" class="tabs ui-helper-clearfix">
  <li><a href="#tab1">Model</a></li>
  <li><a href="#tab2">View</a></li>
  <li><a href="#tab3">Controller</a></li>
</ul>

<div id="tab1" class="tab hidden">
    Model Content
</div>

<div id="tab2" class="tab hidden">
    View Content
</div>

<div id="tab3" class="tab hidden">
    Controller Content
</div>
              
            
!

CSS

              
                @import url(http://fonts.googleapis.com/css?family=Lato:100,400,700);

* {
	font-family: 'Lato', sans-serif;
    font-size: 12px;
    text-shadow: 0 -1px 0 #ffffff;
}
.tabs {
    padding: 0px; 
    margin: 10px 0px 0px 0px;
    position: relative;
    z-index: 1;
    top: 1px;
}
.tabs li {
    float: left;
    padding: 7px 10px;
    background-color: #F6F6F6;
    list-style: none;
    margin-left: 5px;
    border: 1px solid #ccc;
    -webkit-border-top-left-radius: 3px;
    -webkit-border-top-right-radius: 3px;
    -moz-border-radius-topleft: 3px;
    -moz-border-radius-topright: 3px;
    border-top-left-radius: 3px;
    border-top-right-radius: 3px;
}
.tabs li a {
    color: #999;
    font-weight: bold;
    text-decoration: none;
}
.tabs li.active {
    background-color: #fff;
    border-bottom: 1px solid #fff;
}        
.tabs li.active a {
    color: #000;
    cursor: default;
}
.tab {
    border: solid 1px #ccc;
    padding: 10px;   
}

.hidden {
	display: none;
}

/* clearfix from jQueryUI */
.ui-helper-clearfix:after { content: "."; display: block; height: 0; clear: both; visibility: hidden; }
.ui-helper-clearfix { display: inline-block; }
/* required comment for clearfix to work in Opera \*/
* html .ui-helper-clearfix { height:1%; }
.ui-helper-clearfix { display:block; }
              
            
!

JS

              
                import { Component } from "//unpkg.com/can@5/core.mjs"

var Tabs = can.Control.extend({
	// initialize widget
	init: function(el) {
		this.changeActiveTab(el.querySelector('li:first-child'))
	},

	changeActiveTab(newLi) {
		if (this.activeLi == newLi) { return }
		
		// Hide the existing tab contents.
		if (this.activeLi) {
			this.activeLi.classList.remove('active')
			this.getContentForLi(this.activeLi).classList.add('hidden')
		}

		// Show the new tab contents.
		newLi.classList.add('active')
		this.getContentForLi(newLi).classList.remove('hidden')
		
		this.activeLi = newLi
	},
	
	getContentForLi(li) {
		let id = li.querySelector('a').getAttribute('href')
		id = id.replace('#', '')
		let el = document.getElementById(id)
		
		return el
	},
	
	'li click'(el, e) {
		this.changeActiveTab(el)
	}
})
  
// adds the controller to the element
new Tabs('#tabs')
              
            
!
999px

Console