Created
December 16, 2013 08:34
-
-
Save Quinten/7983918 to your computer and use it in GitHub Desktop.
Quick tabs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.tabs { | |
position: relative; | |
padding: 37px 0 0 0; | |
margin-bottom: 2em; | |
} | |
.tabs > ul { | |
position: absolute; | |
top: 0; | |
} | |
.tabs > ul > li { | |
float: left; | |
height: 36px; | |
line-height: 36px; | |
border: 1px #999 solid; | |
border-bottom: none; | |
margin-right: 5px; | |
background: #fafafa; | |
padding: 0 1em; | |
} | |
.tabs > ul > li.active { | |
background: #ffffff; | |
height: 37px; | |
z-index: 2; | |
} | |
.tabs > ul > li a { | |
border-bottom: 0; | |
} | |
.tabs > div > div { | |
padding: 1em; | |
border: 1px #999 solid; | |
background: #ffffff; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div id="product-tabs" class="tabs"> | |
<ul> | |
<li><a href="javascript:void(0)">Tab link 1</a></li> | |
<li><a href="javascript:void(0)">Tab link 2</a></li> | |
<li><a href="javascript:void(0)">Tab link 3</a></li> | |
</ul> | |
<div> | |
<div> | |
<p>content 1</p> | |
</div> | |
<div> | |
<p>content 2</p> | |
</div> | |
<div> | |
<p>content 3</p> | |
</div> | |
</div> | |
</div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jQuery(document).ready(function(){ | |
jQuery('#product-tabs > ul > li:first-child').addClass('active'); | |
jQuery('#product-tabs > div > div').hide(); | |
jQuery('#product-tabs > div > div:first-child').show(); | |
jQuery('#product-tabs > ul > li').click(function () { | |
var nTab = jQuery(this).index() + 1; | |
jQuery('#product-tabs > ul > li').removeClass('active'); | |
jQuery('#product-tabs > ul > li:nth-child('+nTab+')').addClass('active'); | |
jQuery('#product-tabs > div > div').hide(); | |
jQuery('#product-tabs > div > div:nth-child('+nTab+')').show(); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment