Instantly share code, notes, and snippets.
-
Star
0
(0)
You must be signed in to star a gist -
Fork
0
(0)
You must be signed in to fork a gist
-
Save lawliet89/6300830 to your computer and use it in GitHub Desktop.
CSS Navigation Menu
This file contains hidden or 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
@charset "UTF-8"; | |
ul.navigation-menu { // Level 1 | |
.transition() { | |
-webkit-transition: all 300ms ease; | |
-moz-transition: all 300ms ease; | |
-ms-transition: all 300ms ease; | |
-o-transition: all 300ms ease; | |
transition: all 300ms ease; | |
} | |
@text-color: #ffffff; | |
@top-height: 50px; | |
@top-width: 975px; | |
@no-first-level: 5; | |
@bg-color: rgb(54,169,225); | |
@border-color: rgb(43,135,180); | |
@infinity: 9999999px; | |
@sub-width: @top-width/@no-first-level - 1; | |
@radius: 5px; | |
list-style-type: none; | |
list-style-image: none; | |
width: @top-width; | |
height: @top-height; | |
text-align: center; | |
display: inline-block; | |
margin: 0; | |
padding: 0; | |
position: relative; | |
font-family: Helvetica, Arial, sans-serif; | |
color: @text-color; | |
cursor: pointer; | |
ul { | |
list-style-type: none; | |
list-style-image: none; | |
opacity: 0; | |
position: relative; | |
z-index: -999; | |
} | |
/* CSS3 Gradient */ | |
background: @bg-color; | |
a:link, a:visited { | |
text-decoration: none; | |
color: @text-color; | |
display: inline-block; | |
width: 100%; | |
height: 100%; | |
} | |
> li { // level 1 | |
display: block; | |
float: left; | |
line-height: @top-height; | |
height: @top-height; | |
text-align: center; | |
width: (@top-width/@no-first-level)-1px; | |
padding: 0; | |
margin: 0; | |
border-right: 1px solid @border-color; | |
box-shadow: 1px 0 0 rgba(255, 255, 255, 0.5) inset; | |
.transition; | |
> ul { // Level 2 - unshown | |
.transition; | |
list-style-type: none; | |
list-style-image: none; | |
text-align: center; | |
padding: 0; | |
margin: 0; | |
height: 0; | |
> li { // Level 2 - unshown | |
display: block; | |
opacity: 0; | |
padding: 0; | |
margin: 0; | |
height: 0; | |
.transition; | |
} | |
} | |
&:hover { | |
background-color: #a3c4e9; | |
> ul { // Level 2 shown | |
.transition; | |
position: relative; | |
z-index: 9999; | |
height: auto; | |
opacity: 1; | |
border-bottom-left-radius: @radius; | |
border-bottom-right-radius: @radius; | |
box-shadow: 1px 2px @radius rgba(0, 0, 0, 0.5); | |
background: @bg-color; | |
> li { // Level 2 shown | |
opacity: 1; | |
border-bottom: 1px solid @border-color; | |
box-shadow: 0 1px 0 rgba(255, 255, 255, 0.5) inset; | |
height: @top-height; | |
line-height: @top-height; | |
&:first-child { | |
box-shadow: none; | |
} | |
&:last-child { | |
border-bottom: none; | |
} | |
&:hover { | |
background-color: #a3c4e9; | |
} | |
&:active { | |
background-color: #93b4d9; | |
} | |
&.maple { | |
background-image: url('http://2013.igem.org/wiki/images/8/82/MapleLogo.png'); | |
background-size: 65% auto; | |
background-repeat: no-repeat; | |
background-position: 40% 40%; | |
background-color: #ffce32; | |
a { | |
text-indent: -@infinity; | |
} | |
&:hover { | |
background-color: #fff; | |
} | |
&:active { | |
background-color: #ffce32; | |
} | |
} | |
> ul { // Level 3 unshown | |
.transition; | |
list-style-type: none; | |
list-style-image: none; | |
text-align: center; | |
padding: 0; | |
margin: 0; | |
position: relative; | |
left: @sub-width; | |
top: -@top-height; | |
opacity: 1; | |
&:before { | |
content: "»"; | |
display: block; | |
position: absolute; | |
left: -20px; | |
text-align: right; | |
line-height: @top-height; | |
} | |
> li { // Level 3 unshown | |
.transition; | |
width: 0; | |
width: 0; | |
opacity: 0; | |
padding: 0; | |
margin: 0; | |
} | |
&.left { | |
left: 0; | |
right: @sub-width; | |
} | |
} | |
&:hover { | |
> ul { // Level 3 shown | |
height: auto; | |
width: @sub-width; | |
opacity: 1; | |
border-top-right-radius: @radius; | |
border-bottom-left-radius: @radius; | |
border-bottom-right-radius: @radius; | |
box-shadow: 1px 2px @radius rgba(0, 0, 0, 0.5); | |
background: @bg-color; | |
z-index: 9999999; | |
> li { | |
width: @sub-width; | |
height: @top-height; | |
line-height: @top-height; | |
opacity: 1; | |
border-bottom: 1px solid @border-color; | |
box-shadow: 0 1px 0 rgba(255, 255, 255, 0.5) inset; | |
&:first-child { | |
box-shadow: none; | |
border-top-right-radius: @radius; | |
} | |
&:last-child { | |
border-bottom: none; | |
border-bottom-left-radius: @radius; | |
border-bottom-right-radius: @radius; | |
} | |
&:hover { | |
background-color: #a3c4e9; | |
} | |
} | |
} | |
} | |
} | |
} | |
} | |
&:active { | |
background-color: #93b4d9; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment