Created
October 25, 2012 21:05
-
-
Save stirlinghewitt/3955396 to your computer and use it in GitHub Desktop.
dead simple js tabs
This file contains 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="tabMenu"> | |
<ul class="tabs"> | |
<li id="mainSeats"><a href="#mainSeatsContent">1</a></li> | |
<li id="125"><a href="#125Content">1</a></li> | |
<li id="delivery"><a href="#deliveryContent">1</a></li> | |
<li id="tickets"><a href="#ticketsContent">1</a></li> | |
<li id="pricesFees"><a href="#pricesFeesContent">1</a></li> | |
<li id="other"><a href="#otherContent">1</a></li> | |
</ul> | |
<ul class="tabs-content"> | |
<li id="mainSeatsContent" class="active">1</li> | |
<li id="125Content">2</li> | |
<li id="deliveryContent">3</li> | |
<li id="ticketsContent">4</li> | |
<li id="pricesFeesContent">5</li> | |
<li id="otherContent">6</li> | |
</ul> | |
</div> |
This file contains 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 (activate in tabs.js) | |
================================================== */ | |
ul.tabs { | |
display: block; | |
margin: 0 0 20px 0; | |
padding: 0; | |
border-bottom: solid 1px #ddd; } | |
ul.tabs li { | |
display: block; | |
width: auto; | |
height: 30px; | |
padding: 0; | |
float: left; | |
margin-bottom: 0; } | |
ul.tabs li a { | |
display: block; | |
text-decoration: none; | |
width: auto; | |
height: 29px; | |
padding: 0px 20px; | |
line-height: 30px; | |
border: solid 1px #ddd; | |
border-width: 1px 1px 0 0; | |
margin: 0; | |
background: #f5f5f5; | |
font-size: 13px; } | |
ul.tabs li a.active { | |
background: #fff; | |
height: 30px; | |
position: relative; | |
top: -4px; | |
padding-top: 4px; | |
border-left-width: 1px; | |
margin: 0 0 0 -1px; | |
color: #111; | |
-moz-border-radius-topleft: 2px; | |
-webkit-border-top-left-radius: 2px; | |
border-top-left-radius: 2px; | |
-moz-border-radius-topright: 2px; | |
-webkit-border-top-right-radius: 2px; | |
border-top-right-radius: 2px; } | |
ul.tabs li:first-child a.active { | |
margin-left: 0; } | |
ul.tabs li:first-child a { | |
border-width: 1px 1px 0 1px; | |
-moz-border-radius-topleft: 2px; | |
-webkit-border-top-left-radius: 2px; | |
border-top-left-radius: 2px; } | |
ul.tabs li:last-child a { | |
-moz-border-radius-topright: 2px; | |
-webkit-border-top-right-radius: 2px; | |
border-top-right-radius: 2px; } | |
ul.tabs-content { margin: 0; display: block; } | |
ul.tabs-content > li { display:none; } | |
ul.tabs-content > li.active { display: block; } | |
/* Clearfixing tabs for beautiful stacking */ | |
ul.tabs:before, | |
ul.tabs:after { | |
content: '\0020'; | |
display: block; | |
overflow: hidden; | |
visibility: hidden; | |
width: 0; | |
height: 0; } | |
ul.tabs:after { | |
clear: both; } | |
ul.tabs { | |
zoom: 1; } |
This file contains 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
/* | |
* Skeleton V1.1 | |
* Copyright 2011, Dave Gamache | |
* www.getskeleton.com | |
* Free to use under the MIT license. | |
* http://www.opensource.org/licenses/mit-license.php | |
* 8/17/2011 | |
*/ | |
$(document).ready(function() { | |
/* Tabs Activiation | |
================================================== */ | |
var tabs = $('ul.tabs'); | |
tabs.each(function(i) { | |
//Get all tabs | |
var tab = $(this).find('> li > a'); | |
tab.click(function(e) { | |
//Get Location of tab's content | |
var contentLocation = $(this).attr('href'); | |
//Let go if not a hashed one | |
if(contentLocation.charAt(0)=="#") { | |
e.preventDefault(); | |
//Make Tab Active | |
tab.removeClass('active'); | |
$(this).addClass('active'); | |
//Show Tab Content & add active class | |
$(contentLocation).show().addClass('active').siblings().hide().removeClass('active'); | |
} | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment