Skip to content

Instantly share code, notes, and snippets.

@kaelig
Created January 17, 2011 15:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kaelig/782927 to your computer and use it in GitHub Desktop.
Save kaelig/782927 to your computer and use it in GitHub Desktop.
CSS Navigation : refactored
$navheight: 61px;
#navigation {
list-style-type: none;
margin: 0;
padding: 0;
height: $navheight;
ul {
list-style-type: none;
margin: 0;
padding: 0;
}
li {
display: inline;
float: left;
margin: 0;
height: $navheight;
padding: 0;
}
a {
display: inline;
float: left;
padding-top: $navheight;
height: 0;
overflow: hidden;
background: url('../images/navigation.png') 0 0 no-repeat;
}
}
$n1: 45px;
$n2: 93px;
$n3: 93px;
$n4: 60px;
@mixin nav($w, $p, $class) {
width: $w;
background-position: -($p) 0;
.#{$class} &,
&:hover {
background-position: -($p) (-($navheight));
}
}
/* Active state when body has a certain class */
#n1 a { @include nav($n1, 0, 'homepage'); }
#n2 a { @include nav($n2, $n1, 'about-us'); }
#n3 a { @include nav($n3, #{$n2 + $n1}, 'news'); }
#n4 a { @include nav($n4, #{$n3 + $n2 + $n1}, 'contact'); }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment