Skip to content

Instantly share code, notes, and snippets.

@tessalt
Created November 16, 2012 15:15
Show Gist options
  • Save tessalt/4088085 to your computer and use it in GitHub Desktop.
Save tessalt/4088085 to your computer and use it in GitHub Desktop.
tabs
$(".tabs > li > a").click (e) ->
e.preventDefault()
$(".tab").removeClass "active"
$(".tabs > li > a").removeClass "active"
targetTab = $(this).attr("href")
$(targetTab).addClass "active"
$(this).addClass "active"
$(".tabs > li > a").click(function(e){
e.preventDefault();
$(".tab").removeClass("active");
$(".tabs > li > a").removeClass("active");
var targetTab = $(this).attr("href");
$(targetTab).addClass("active");
$(this).addClass("active")
});
.tabs {
overflow: hidden;
&>li {
display: inline-block;
vertical-align: top;
&>a {
display: inline-block;
text-decoration: none;
color: #272727;
padding: 10px 15px;
margin-right: 5px;
border-radius: 5px 5px 0 0;
background: #fff;
position: relative;
z-index: 10;
&.active {
background: #f1f1f1;
}
}
}
}
.tab {
display: none;
margin-top: -1px;
position: relative;
z-index: 5;
&.active {
display: block;
}
}
ul.tabs
li
a href="#projects-tab" class="active" Projects
li
a href="#people-tab" People
#projects-tab.tab.active
// tab content
#people-tab.tab
// tab content
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment