Skip to content

Instantly share code, notes, and snippets.

@stevetrask
Created August 25, 2015 20:28
Show Gist options
  • Save stevetrask/3fcf3ecea14a3b2e81b1 to your computer and use it in GitHub Desktop.
Save stevetrask/3fcf3ecea14a3b2e81b1 to your computer and use it in GitHub Desktop.
// custom menu styles
$menu-bkg: #666;
/* Since we'll have the "ul li" "float:left"
* we need to add a clear after the container. */
nav:after {
content:"";
display:table;
clear:both;
}
/* Removing padding, margin and "list-style" from the "ul",
* and adding "position:reltive" */
nav {
ul {
padding: 0;
margin: 0;
list-style: none;
position: relative;
/* Positioning the navigation items inline */
li {
margin: 0px;
display:inline-block;
float: left;
background-color: $menu-bkg;
}
}
> ul > li {
border-radius: 3px;
margin-left: 5px;
}
/* Styling the links */
a {
display: block;
padding: 0 20px;
color: #FFF;
font-size: 16px;
line-height: 40px;
text-decoration: none;
/* Background color change on Hover */
&:hover {
background: darken($menu-bkg, 10%);
}
}
/* Hide Dropdowns by Default
* and giving it a position of absolute */
ul ul {
display: none;
position: absolute;
/* has to be the same number as the "line-height" of "nav a" */
top: 40px;
}
/* Display Dropdowns on Hover */
ul li:hover > ul {
display:inherit;
}
/* First Tier Dropdown */
ul ul li {
width: 170px;
float: none;
display: list-item;
position: relative;
}
/* Second, Third and more Tiers
* We move the 2nd and 3rd etc tier dropdowns to the left
* by the amount of the width of the first tier.
*/
ul ul ul li {
position: relative;
top: -40px;
/* has to be the same number as the "width" of "nav ul ul li" */
left: 170px;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment