[CSS]これはちょっと使いたくなる、キーフレームを使ったCSS3アニメーションのナビゲーション
Post on:2012年1月18日
sponsorsr
Flashも無し、jQueryも無し、キーフレームを使ったCSS3アニメーションで実装したかっこいいドロップダウン型のナビゲーションを紹介します。

[ad#ad-2]
デモ
デモはキーフレームのアニメーションを使用しているため、Chrome, Safari,Firefoxでご覧ください。
※IE, Operaでは動作しません。

デモページ: ノーマル時

デモページ: ホバー時
ホバーすると、下から半透明のパネルがふわりとスライドします。
[ad#ad-2]

デモページ: アニメーション完了時
実装
HTML
ナビゲーションはリスト要素で実装されており、第二レベルはリストの入れ子になっています。
<div id="container"> <ul id="nav"> <li><a href="#">Home</a></li> <li> <a href="#">About Us</a> <ul> <li><a href="#">What we do</a></li> <li><a href="#">Who we are</a></li> <li><a href="#">I love this menu. Its Awesome!</a></li> </ul> </li> <li> <a href="#">Services</a> <ul> <li><a href="#">Web Designing</a></li> <li><a href="#">Motion Graphics</a></li> <li><a href="#">Web Development (PHP, Python)</a></li> <li><a href="#">Photography</a></li> </ul> </li> <li><a href="#">Portfolio</a></li> <li><a href="#">Talk to us</a></li> </ul> </div>
CSS
キーフレームのアニメーションも素晴らしいですが、基本のスタイルもグラデーションを使って美しいものとなっています。
/****************************
Two Level Superfishy CSS3 Menu
By Solitary Designs: http://solitarydesigns.net
****************************/
#container {
width: 600px;
position: relative;
margin: 20px auto 0;
}
ul#nav {
list-style: none;
height: 36px;
padding: 0;
float:left;
margin-left: 100px;
border: 1px solid #b3b3b3;
position: relative;
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px;
}
ul#nav>li {
float: left;
border-top: 1px solid white;
position: relative;
background-repeat: no-repeat;
background-color: #cfcfcf; /* Old browsers */
background-image: -moz-linear-gradient(top, #e3e3e3 0%, #cfcfcf 100%); /* FF3.6+ */
background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#e3e3e3), color-stop(100%,#cfcfcf)); /* Chrome,Safari4+ */
background-image: -webkit-linear-gradient(top, #e3e3e3 0%,#cfcfcf 100%); /* Chrome10+,Safari5.1+ */
background-image: -o-linear-gradient(top, #e3e3e3 0%,#cfcfcf 100%); /* Opera 11.10+ */
background-image: -ms-linear-gradient(top, #e3e3e3 0%,#cfcfcf 100%); /* IE10+ */
background-image: linear-gradient(top, #e3e3e3 0%,#cfcfcf 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#e3e3e3', endColorstr='#cfcfcf',GradientType=0 ); /* IE6-8 */
-webkit-transition: all .2s ease;
-moz-transition: all .2s ease;
-ms-transition: all .2s ease;
-o-transition: all .2s ease;
transition: all .2s ease;
}
ul#nav>li:hover {
background-position: 0 -10px;
}
ul#nav > li:hover ul{
-webkit-animation: anim .2s forwards linear;
-moz-animation: anim .2s forwards linear;
-ms-animation: anim .2s forwards linear;
-o-animation: anim .2s forwards linear;
animation: anim .2s forwards linear;
}
ul#nav>li:hover>a {
color: white;
}
ul#nav>li>a {
padding: 10px 15px;
color: #777;
text-decoration: none;
font: 12px Arial;
border-left: 1px solid #bababa;
border-right: 1px solid #eee;
display: block;
line-height: 15px;
-webkit-transition: all .2s ease;
-moz-transition: all .2s ease;
-ms-transition: all .2s ease;
-o-transition: all .2s ease;
transition: all .2s ease;
}
ul#nav>li:first-child>a, ul#nav>li:first-child {
border-left: none;
-webkit-border-radius: 4px 0 0 4px;
-moz-border-radius: 4px 0 0 4px;
border-radius: 4px 0 0 4px;
}
ul#nav li:last-child a, ul#nav li:last-child {
border-right: none;
-webkit-border-radius: 0 4px 4px 0;
-moz-border-radius: 0 4px 4px 0;
border-radius: 0 4px 4px 0;
}
/* 2nd Level */
ul#nav > li > ul {
position: absolute;
list-style: none;
padding: 0;
background: #cfcfcf;
top: 55px;
width: 230px;
border-radius: 0 0 4px 4px;
border: 1px solid #b3b3b3;
overflow: hidden;
opacity: 0;
left: -999px;
}
ul#nav > li > ul > li {
padding: 10px 0 10px 0;
border-top: 1px solid #aaa;
border-bottom: 1px solid #efefef;
-webkit-transition: all .2s ease;
-moz-transition: all .2s ease;
-ms-transition: all .2s ease;
-o-transition: all .2s ease;
transition: all .2s ease;
}
ul#nav > li > ul > li:hover {
background: #bbb;
border-top: 1px solid #999;
border-bottom: 1px solid #fff;
}
ul#nav > li > ul > li:hover a {
color: white;
}
ul#nav > li > ul > li:first-child {
border-top: none;
}
ul#nav > li > ul > li:last-child {
border-bottom: none;
}
ul#nav > li > ul > li > a {
color: #777;
text-decoration: none;
padding: 10px 20px 10px 15px;
font: 12px Arial;
-webkit-transition: all .2s ease;
-moz-transition: all .2s ease;
-ms-transition: all .2s ease;
-o-transition: all .2s ease;
transition: all .2s ease;
}
@-webkit-keyframes anim {
0% { left:0; opacity: 0}
100% {left: 0; top: 35px; opacity: 1}
}
@-moz-keyframes anim {
0% { left:0; opacity: 0}
100% {left: 0; top: 35px; opacity: 1}
}
@-ms-keyframes anim {
0% { left:0; opacity: 0}
100% {left: 0; top: 35px; opacity: 1}
}
@-o-keyframes anim {
0% { left:0; opacity: 0}
100% {left: 0; top: 35px; opacity: 1}
}
@keyframes anim {
0% { left:0; opacity: 0}
100% {left: 0; top: 35px; opacity: 1}
}
sponsors











