Skip to content

Instantly share code, notes, and snippets.

@chronon
Created May 22, 2013 18:25
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 chronon/5629768 to your computer and use it in GitHub Desktop.
Save chronon/5629768 to your computer and use it in GitHub Desktop.
Simple, not very styled, CSS only cross browser dropdown menu sass/scss mixin.
// Sort of based on http://matthewjamestaylor.com/blog/centered-dropdown-menus
// but with centering elements removed.
@mixin navmenu($z-index, $width) {
clear: both;
float: left;
margin: 0;
padding: 0;
width: 100%;
z-index: $z-index;
position: relative;
ul {
margin: 0;
padding: 0;
list-style: none;
float: right;
position: relative;
li {
margin: 0 0 0 1px;
padding: 0;
float: left;
position: relative;
top: 1px;
a {
display: block;
margin: 0;
padding: .6em .5em .4em;
}
&:last-child ul {
left: auto;
right: 0;
text-align: right;
}
&:hover ul { display: block; }
}
ul {
display: none;
position: absolute;
top: 2em;
left: 0;
right: auto;
width: $width;
li {
left: auto;
margin: 0;
clear: left;
width: 100%;
a, &:hover ul li a {
background: #eee;
color: #444;
line-height: 1.4em;
}
a:hover, &:hover ul li a:hover {
background: #ddd;
color: $hover-color;
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment