jQuery Simple Tabs Demo
by anay1231
HTML
<ul class="tabs-nav">
<li class=""><a href="#tab-1" rel="nofollow">Features</a>
</li>
<li class="tab-active"><a href="#tab-2" rel="nofollow">Details</a>
</li>
<li class="tab-active"><a href="#tab-3" rel="nofollow">Details info</a>
</li>
</ul>
<div class="tabs-stage">
<div id="tab-1" style="display: none;">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus nec neque nisi, dictum aliquet lectus.</p>
</div>
<div id="tab-2" style="display: block;">
<p>Phasellus pharetra aliquet viverra. Donec scelerisque tincidunt diam, eu fringilla urna auctor at.</p>
</div>
<div id="tab-3">
<p>Phasellus pharetra aliquet viverra. Donec scelerisque tincidunt diam, eu fringilla urna auctor at hfgdfdt.</p>
</div>
</div>
CSS
ul, li, div {
background: hsla(0, 0%, 0%, 0);
border: 0;
font-size: 100%;
margin: 0;
outline: 0;
padding: 0;
vertical-align: baseline;
font: 13px/20px "Droid Sans", Arial, "Helvetica Neue", "Lucida Grande", sans-serif;
text-shadow: 0 1px 0 hsl(0, 100%, 100%);
}
li {
display: list-item;
text-align: -webkit-match-parent;
}
.tabs-nav {
list-style: none;
margin: 0;
padding: 0;
}
.tabs-nav li:first-child a {
border-right: 0;
-moz-border-radius-topleft: 6px;
-webkit-border-top-left-radius: 6px;
border-top-left-radius: 6px;
}
.tabs-nav .tab-active a {
background: hsl(0, 100%, 100%);
border-bottom-color: hsla(0, 0%, 0%, 0);
color: hsl(85, 54%, 51%);
cursor: default;
}
.tabs-nav a {
background: hsl(120, 11%, 96%);
border: 1px solid hsl(210, 6%, 79%);
color: hsl(215, 6%, 57%);
display: block;
font-size: 11px;
font-weight: bold;
height: 40px;
line-height: 44px;
text-align: center;
text-transform: uppercase;
width: 140px;
}
.tabs-nav li {
float: left;
}
.tabs-stage {
border: 1px solid hsl(210, 6%, 79%);
-webkit-border-radius: 0 0 6px 6px;
-moz-border-radius: 0 0 6px 6px;
-ms-border-radius: 0 0 6px 6px;
-o-border-radius: 0 0 6px 6px;
border-radius: 0 0 6px 6px;
border-top: 0;
clear: both;
margin-bottom: 20px;
position: relative;
top: -1px;
width: 100%;
}
.tabs-stage p {
margin: 0;
padding: 20px;
color: hsl(0, 0%, 33%);
}
JavaScript
// From http://learn.shayhowe.com/advanced-html-css/jquery
// Change tab class and display content
$('.tabs-nav a').on('click', function (event) {
event.preventDefault();
$('.tab-active').removeClass('tab-active');
$(this).parent().addClass('tab-active');
$('.tabs-stage div').hide();
$($(this).attr('href')).show();
});
$('.tabs-nav a:first').trigger('click'); // Default