Created
April 24, 2019 17:44
-
-
Save halfnibble/0418eeb662fbd60f20ec862d863cbe29 to your computer and use it in GitHub Desktop.
SCSS for responsive nav
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
@import "bourbon/bourbon"; | |
@import "colors"; | |
@import url('https://fonts.googleapis.com/css?family=Inconsolata'); | |
@import "grid"; | |
@import "utils"; | |
$parent_menu_items: 3; | |
$submenu_menu_items: 4; | |
html, body { | |
margin: 0; | |
padding: 0; | |
} | |
ul, li { | |
list-style-type: none; | |
margin: 0; | |
padding: 0; | |
box-sizing: border-box; | |
} | |
nav { | |
> ul { | |
height: 36px; | |
@include clearfix; | |
background-color: $light-blue; | |
} | |
> ul > li { | |
font-size: 1.15em; | |
@include size(medium-up) { | |
display: inline-block; | |
width: percentage((1/$parent_menu_items)); | |
a { | |
border-right: 0.05em solid $white; | |
} | |
} | |
&:last-child a { | |
border-right: none; | |
} | |
} | |
> ul.closed > li { | |
display: none; | |
@include size(medium-up) { | |
display: block; | |
float: left; | |
} | |
} | |
a { | |
font-family: 'Inconsolata', monospace; | |
box-sizing: border-box; | |
height: 36px; | |
background-color: $light-blue; | |
color: $white; | |
border-bottom: 0.1em solid $white; | |
text-decoration: none; | |
display: block; | |
padding: 6px 8px; | |
text-align: center; | |
&:hover { | |
background-color: $dark-blue; | |
} | |
} | |
// .submenu-parent { | |
// ul { | |
// display: none; | |
// } | |
// &:hover ul { | |
// display: block; | |
// } | |
// } | |
.submenu { | |
display: none; | |
@include size(medium) { | |
position: absolute; | |
left: 0; | |
top: 35px; | |
width: 100%; | |
li { | |
display: inline-block; | |
margin-right: -5px; | |
width: percentage((1/$submenu_menu_items)); | |
a { | |
border: 0; | |
} | |
} | |
} | |
a { | |
border-bottom: none; | |
} | |
li:last-child { | |
a { | |
@include size(small) { | |
border-bottom: 0.05em solid $white; | |
} | |
} | |
} | |
} | |
} | |
#mobile-menu { | |
display: block; | |
@include size(medium-up) { | |
display: none; | |
} | |
} | |
#hamburger { | |
$icon-width: 22px; | |
float: left; | |
margin: 2px -#{$icon-width} 2px 0; | |
width: $icon-width; | |
height: 16px; | |
background-image: url('../img/Hamburger.png'); | |
background-size: cover; | |
} | |
ul.open #hamburger { | |
$icon-width: 16px; | |
margin: 2px -#{$icon-width} 2px 0; | |
width: $icon-width; | |
height: $icon-width; | |
background-image: url('../img/X-Icon.png'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment