JavaScript preprocessors can help make authoring JavaScript easier and more convenient. For instance, CoffeeScript can help prevent easy-to-make mistakes and offer a cleaner syntax and Babel can bring ECMAScript 6 features to browsers that only support ECMAScript 5.
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.
You can apply a script from anywhere on the web to your Pen. Just put a URL to it here and we'll add it, in the order you have them, before the JavaScript in the Pen itself.
If the script you link to has the file extension of a preprocessor, we'll attempt to process it before applying.
You can also link to another Pen here, and we'll pull the JavaScript from that Pen and include it. If it's using a matching preprocessor, we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
HTML Settings
Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/3.0.2/normalize.css"/>
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css">
<div id="wrapper">
<section id="generic-tabs">
<h1 class="callout">Reponsive jQuery tabs</h1>
<ul id="tabs">
<li>
<a title="Home" href="#first-tab"><i class="fa fa-home"></i> Home</a>
</li>
<li>
<a title="Photos" href="#second-tab"><i class="fa fa-picture-o"></i> Photos</a>
</li>
<li>
<a title="About" href="#third-tab"><i class="fa fa-info-circle"></i> About</a>
</li>
<li>
<a title="Contact" href="#fourth-tab"><i class="fa fa-envelope"></i> Contact</a>
</li>
</ul>
<div id="first-tab" class="tab-content">
<h1>Home</h1>
<p><strong>Hey there, <a href="https://cliftwalker.co.uk">Jonathan Clift</a> here! I created these tabs as I find myself recreating this tab style over and over again. Use them as you please and let me know what you think.</strong></p>
<p>Lorem ipsum dolor sit amet, utroque splendide an quo. Omnesque pertinacia efficiantur vix at, soleat quaeque assueverit et vis. Te sit tale eripuit corrumpit, cum ea case graeci legimus. Sea ex assentior honestatis adversarium. Mei ea dico meis instructior, no eum ipsum voluptatum, quodsi pertinax postulant in sed. Te eum pertinacia suscipiantur, sea eirmod sanctus ea. Vel habeo feugait ea, an apeirian adversarium nam.</p>
</div>
<div id="second-tab" class="tab-content">
<h1>Twitter office photo!</h1>
<a href="https://www.flickr.com/photos/twitteroffice/15437700946" title="Twitter Boston by Twitter, on Flickr"><img src="https://farm3.staticflickr.com/2948/15437700946_3dec413dd2_b.jpg" alt="Twitter Boston"></a>
<p>Lorem ipsum dolor sit amet, utroque splendide an quo. Omnesque pertinacia efficiantur vix at, soleat quaeque assueverit et vis. Te sit tale eripuit corrumpit, cum ea case graeci legimus. Sea ex assentior honestatis adversarium. Mei ea dico meis instructior, no eum ipsum voluptatum, quodsi pertinax postulant in sed. Te eum pertinacia suscipiantur, sea eirmod sanctus ea. Vel habeo feugait ea, an apeirian adversarium nam.</p>
</div>
<div id="third-tab" class="tab-content">
<h1>About</h1>
<p>Lorem ipsum dolor sit amet, utroque splendide an quo. Omnesque pertinacia efficiantur vix at, soleat quaeque assueverit et vis. Te sit tale eripuit corrumpit, cum ea case graeci legimus. Sea ex assentior honestatis adversarium. Mei ea dico meis instructior, no eum ipsum voluptatum, quodsi pertinax postulant in sed. Te eum pertinacia suscipiantur, sea eirmod sanctus ea. Vel habeo feugait ea, an apeirian adversarium nam.</p>
</div>
<div id="fourth-tab" class="tab-content">
<h1>Contact</h1>
<p>Lorem ipsum dolor sit amet, utroque splendide an quo. Omnesque pertinacia efficiantur vix at, soleat quaeque assueverit et vis. Te sit tale eripuit corrumpit, cum ea case graeci legimus. Sea ex assentior honestatis adversarium. Mei ea dico meis instructior, no eum ipsum voluptatum, quodsi pertinax postulant in sed. Te eum pertinacia suscipiantur, sea eirmod sanctus ea. Vel habeo feugait ea, an apeirian adversarium nam.</p>
</div>
</section>
</div>
body{font: 67.5% Helvetica, Arial, Sans-serif; background:#2c3e50;}
/*Box sizing stuff*/
* { -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box;}
/*Font styels*/
h1 {font-weight: normal; font-size:1.6em;}
h1.callout{color:#FFFFFF; font-size:2em; margin:1em 0;}
p{font-size: 1.2em; color:#a3a3a3 ; line-height: 1.5;}
p strong{color:#555555;}
p a{color:#27ae60; text-decoration:none;}
/*img stuff*/
img {max-width: 100%;}
/*Generic styles*/
#wrapper{ max-width: 800px; width:100%; margin:0 auto;}
#generic-tabs{ width:100%; padding:20px;}
/*Tab styles*/
#generic-tabs ul { overflow: hidden; margin:0; padding:0;}
#generic-tabs ul li{ float:left; display:inline-block; width:25%; background:#EDEDED; border-top:4px solid #CCCCCC; border-right:1px solid #CCCCCC;}
#generic-tabs ul li:last-child {border-right:none;}
#generic-tabs ul li:first-child { padding-left:0; }
/*Tab link styles*/
#generic-tabs ul li a {text-align:center; display:block; font-size: 1.2em; text-decoration: none; padding: 1.2em 1em; line-height: 16px; color:#BBBBBB;}
/*Active tab styles*/
#generic-tabs ul li.active {background:#FFFFFF; border-top:4px solid #27ae60;}
#generic-tabs ul li.active a { color:#333333;}
#generic-tabs ul li.active a i {color:#27ae60;}
/*Tab content styles*/
#generic-tabs .tab-content{ background:#FFFFFF; padding:3em 2em;}
#generic-tabs .tab-content h1 {margin-top:0;}
@media only screen and (min-width: 650px) {
h1{font-size:2em;}
h1.callout{font-size:3em;}
p{font-size:1.4em;}
#generic-tabs ul li a { font-size:1.6em; padding: 1.2em 2em; line-height: 16px; }
}
(function($){
/* trigger when page is ready */
$(document).ready(function (){
//Tabs functionality
//Firstly hide all content divs
$('#generic-tabs div').hide();
//Then show the first content div
$('#generic-tabs div:first').show();
//Add active class to the first tab link
$('#generic-tabs ul#tabs li:first').addClass('active');
//Functionality when a tab is clicked
$('#generic-tabs ul#tabs li a').click(function(){
//Firstly remove the current active class
$('#generic-tabs ul#tabs li').removeClass('active');
//Apply active class to the parent(li) of the link tag
$(this).parent().addClass('active');
//Set currentTab to this link
var currentTab = $(this).attr('href');
//Hide away all tabs
$('#generic-tabs div').hide();
//show the current tab
$(currentTab).show();
//Stop default link action from happening
return false;
});
});
})(window.jQuery);
Also see: Tab Triggers