Created
November 15, 2012 16:34
-
-
Save johnheimkes/4079583 to your computer and use it in GitHub Desktop.
A CodePen by John Heimkes IV. CSS Swinging Panel Menu - A simple, clean pure CSS menu that uses keyframe animation to create a "swining panel" effect for sub nav. I am having trouble getting it to work in Opera but performs well in Chrome, Safari and Fire
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
<div id="container"> | |
<ul id="menu"> | |
<li><a href="#">About Me</a> | |
<ul> | |
<li><a href="#">Lorem ipsum dolor</a></li> | |
<li><a href="#">Maecenas lacinia sem</a></li> | |
<li><a href="#">Suspendisse fringilla</a></li> | |
</ul> | |
</li> | |
<li><a href="#">Portfolio</a> | |
<ul> | |
<li><a href="#">Lorem ipsum dolor</a></li> | |
<li><a href="#">Maecenas dignissim fermentum luctus</a></li> | |
<li><a href="#">Suspendisse fringilla</a></li> | |
<li><a href="#">Lorem ipsum dolor</a></li> | |
<li><a href="#">Maecenas lacinia sem</a></li> | |
<li><a href="#">Suspendisse fringilla</a></li> | |
</ul> | |
</li> | |
<li><a href="#">Clients</a> | |
<ul> | |
<li><a href="#">Lorem ipsum dolor</a></li> | |
<li><a href="#">Maecenas lacinia sem</a></li> | |
<li><a href="#">Suspendisse fringilla</a></li> | |
</ul> | |
</li> | |
<li><a href="#">Contact Me</a> | |
<ul> | |
<li><a href="#">Lorem ipsum dolor</a></li> | |
<li><a href="#">Maecenas dignissim fermentum luctus</a></li> | |
<li><a href="#">Suspendisse fringilla</a></li> | |
</ul> | |
</li> | |
<li><a href="#">Support</a></li> | |
</ul> | |
</div> |
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
* { | |
margin: 0; | |
padding: 0; | |
-webkit-box-sizing: border-box; | |
-moz-box-sizing: border-box; | |
box-sizing: border-box; | |
} | |
body { | |
padding: 30px; | |
font-family: "Helvetica Neue", helvetica, arial; | |
background: url('http://subtlepatterns.com/patterns/white_carbonfiber.png'); | |
} | |
#container { | |
position: relative; | |
width: 940px; | |
} | |
#container:after { | |
content: ""; | |
display: block; | |
clear: both; | |
height: 0; | |
} | |
#menu { | |
position: relative; | |
float: left; | |
width: 100%; | |
padding: 0 20px; | |
border-radius: 3px; | |
box-shadow: inset 0 1px 1px rgba(255,255,255,.5), inset 0 -1px 0 rgba(0,0,0,.15), 0 1px 3px rgba(0,0,0,.15); | |
background: #ccc; | |
} | |
#menu, #menu ul { | |
list-style: none; | |
} | |
#menu > li { | |
float: left; | |
position: relative; | |
border-right: 1px solid rgba(0,0,0,.1); | |
box-shadow: 1px 0 0 rgba(255,255,255,.25); | |
-webkit-perspective: 1000px; | |
-webkit-transform-style: preserver-3d; | |
-moz-perspective: 1000px; | |
-moz-transform-style: preserver-3d; | |
-ms-perspective: 1000px; | |
-ms-transform-style: preserver-3d; | |
-o-perspective: 1000px; | |
-o-transform-style: preserver-3d; | |
perspective: 1000px; | |
transform-style: preserver-3d; | |
} | |
#menu > li:first-child { | |
border-left: 1px solid rgba(255,255,255,.25); | |
box-shadow: -1px 0 0 rgba(0,0,0,.1), 1px 0 0 rgba(255,255,255,.25); | |
} | |
#menu li.search { | |
border-right: none; | |
box-shadow: none; | |
} | |
#menu a { | |
display: block; | |
position: relative; | |
z-index: 10; | |
padding: 13px 20px 13px 20px; | |
text-decoration: none; | |
color: rgba(75,75,75,1); | |
line-height: 1; | |
font-weight: 600; | |
font-size: 12px; | |
letter-spacing: -.05em; | |
background: transparent; | |
text-shadow: 0 1px 1px rgba(255,255,255,.9); | |
-webkit-transition: all .25s ease-in-out; | |
-moz-transition: all .25s ease-in-out; | |
-o-transition: all .25s ease-in-out; | |
-ms-transition: all .25s ease-in-out; | |
transition: all .25s ease-in-out; | |
} | |
#menu > li:hover > a { | |
background: #333; | |
color: rgba(0,223,252,1); | |
text-shadow: none; | |
} | |
#menu li ul { | |
position: absolute; | |
left: 0; | |
z-index: 1; | |
width: 200px; | |
padding: 0; | |
opacity: 0; | |
visibility: hidden; | |
border-bottom-left-radius: 4px; | |
border-bottom-right-radius: 4px; | |
background: transparent; | |
overflow: hidden; | |
-webkit-transform-origin: 50% 0%; | |
-moz-transform-origin: 50% 0%; | |
-o-transform-origin: 50% 0%; | |
-ms-transform-origin: 50% 0%; | |
transform-origin: 50% 0%; | |
} | |
#menu li:hover ul { | |
padding: 15px 0; | |
background: #333; | |
opacity: 1; | |
visibility: visible; | |
box-shadow: 1px 1px 7px rgba(0,0,0,.5); | |
-webkit-animation-name: swingdown; | |
-webkit-animation-duration: 1s; | |
-webkit-animation-timing-function: ease; | |
-moz-animation-name: swingdown; | |
-moz-animation-duration: 1s; | |
-moz-animation-timing-function: ease; | |
-o-animation-name: swingdown; | |
-o-animation-duration: 1s; | |
-o-animation-timing-function: ease; | |
-ms-animation-name: swingdown; | |
-ms-animation-duration: 1s; | |
-ms-animation-timing-function: ease; | |
animation-name: swingdown; | |
animation-duration: 1s; | |
animation-timing-function: ease; | |
} | |
@-webkit-keyframes swingdown { | |
0% { | |
opacity: 0; | |
-webkit-transform: rotateX(90deg); | |
} | |
10% { | |
opacity: 1; | |
} | |
30% { | |
-webkit-transform: rotateX(-20deg) rotateY(-10deg); | |
-webkit-animation-timing-function: ease-in-out; | |
} | |
65% { | |
-webkit-transform: rotateX(20deg) rotateY(5deg); | |
-webkit-animation-timing-function: ease-in-out; | |
} | |
100% { | |
-webkit-transform: rotateX(0); | |
-webkit-animation-timing-function: ease-in-out; | |
} | |
} | |
@-moz-keyframes swingdown { | |
0% { | |
opacity: 0; | |
-moz-transform: rotateX(90deg); | |
} | |
10% { | |
opacity: 1; | |
} | |
30% { | |
-moz-transform: rotateX(-20deg) rotateY(-10deg); | |
-moz-animation-timing-function: ease-in-out; | |
} | |
65% { | |
-moz-transform: rotateX(20deg) rotateY(5deg); | |
-moz-animation-timing-function: ease-in-out; | |
} | |
100% { | |
-moz-transform: rotateX(0); | |
-moz-animation-timing-function: ease-in-out; | |
} | |
} | |
@-o-keyframes swingdown { | |
0% { | |
opacity: 0; | |
-o-transform: rotateX(90deg); | |
} | |
10% { | |
opacity: 1; | |
} | |
30% { | |
-o-transform: rotateX(-20deg) rotateY(-10deg); | |
-o-animation-timing-function: ease-in-out; | |
} | |
65% { | |
-o-transform: rotateX(20deg) rotateY(5deg); | |
-o-animation-timing-function: ease-in-out; | |
} | |
100% { | |
-o-transform: rotateX(0); | |
-o-animation-timing-function: ease-in-out; | |
} | |
} | |
@-ms-keyframes swingdown { | |
0% { | |
opacity: 0; | |
-ms-transform: rotateX(90deg); | |
} | |
10% { | |
opacity: 1; | |
} | |
30% { | |
-ms-transform: rotateX(-20deg) rotateY(-10deg); | |
-ms-animation-timing-function: ease-in-out; | |
} | |
65% { | |
-ms-transform: rotateX(20deg) rotateY(5deg); | |
-ms-animation-timing-function: ease-in-out; | |
} | |
100% { | |
-ms-transform: rotateX(0); | |
-ms-animation-timing-function: ease-in-out; | |
} | |
} | |
@keyframes swingdown { | |
0% { | |
opacity: 0; | |
transform: rotateX(90deg); | |
} | |
10% { | |
opacity: 1; | |
} | |
30% { | |
transform: rotateX(-20deg) rotateY(-10deg); | |
animation-timing-function: ease-in-out; | |
} | |
65% { | |
transform: rotateX(20deg) rotateY(5deg); | |
animation-timing-function: ease-in-out; | |
} | |
100% { | |
transform: rotateX(0); | |
animation-timing-function: ease-in-out; | |
} | |
} | |
#menu li li a { | |
padding-left: 15px; | |
font-weight: 400; | |
color: #ddd; | |
text-shadow: none; | |
border-top: dotted 1px transparent; | |
border-bottom: dotted 1px transparent; | |
-webkit-transition: all .15s linear; | |
-moz-transition: all .15s linear; | |
-o-transition: all .15s linear; | |
-ms-transition: all .15s linear; | |
transition: all .15s linear; | |
} | |
#menu li li a:hover { | |
color: rgba(0,223,252,1); | |
border-top: dotted 1px rgba(255,255,255,.15); | |
border-bottom: dotted 1px rgba(255,255,255,.15); | |
background: rgba(0,223,252,.02); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment