Created
April 16, 2012 18:38
-
-
Save octavioamu/2400594 to your computer and use it in GitHub Desktop.
Tabs from Skeleton
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
<!-- Standard <ul> with class of "tabs" --> | |
<ul class="tabs"> | |
<!-- Give href an ID value of corresponding "tabs-content" <li>'s --> | |
<li><a class="active" href="#simple">Simple</a></li> | |
<li><a href="#lightweight">Lightweight</a></li> | |
<li><a href="#mobileFriendly">Mobile</a></li> | |
</ul> | |
<!-- Standard <ul> with class of "tabs-content" --> | |
<ul class="tabs-content"> | |
<!-- Give ID that matches HREF of above anchors --> | |
<li class="active" id="simple">The tabs are clean and simple unordered-list markup and basic CSS.</li> | |
<li id="lightweight">The tabs are cross-browser, but don't need a ton of hacky CSS or markup.</li> | |
<li id="mobileFriendly">The tabs work like a charm even on mobile devices.</li> | |
</ul> |
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 from Skeleton | |
*/ | |
(function ($) { | |
// hash change handler | |
function hashchange () { | |
var hash = window.location.hash | |
, el = $('ul.tabs [href*="' + hash + '"]') | |
, content = $(hash) | |
if (el.length && !el.hasClass('active') && content.length) { | |
el.closest('.tabs').find('.active').removeClass('active'); | |
el.addClass('active'); | |
content.show().addClass('active').siblings().hide().removeClass('active'); | |
} | |
} | |
// listen on event and fire right away | |
$(window).on('hashchange.skeleton', hashchange); | |
hashchange(); | |
$(hashchange); | |
})(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment