以下是 css3彩带导航菜单特效代码 的示例演示效果:
部分效果截图:
HTML代码(index.html):
<!DOCTYPE HTML>
<html lang="en-US">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>css3彩带导航菜单</title>
<link rel="stylesheet" type="text/css" href="zzsc.css" media="all" />
<style>
body {
background-color: #8e949f;
}
#nav {
width: 780px;
height: 85px;
padding-top: 50px;
margin: 40px auto;
border-radius: 5px;
box-shadow: 0 0 10px rgba(0,0,0,.2),0 0 10px rgba(0,0,0,.1) inset;
background-color: #eeeeee;
}
#nav ul {
position: relative;
width: 800px;
height: 40px;
line-height: 40px;
padding: 1px;
margin-left: -10px;
border-radius: 3px;
background-color: #26211a;
}
#nav ul:before,
#nav ul:after {
display: inline-block;
position: absolute;
border-style: solid;
border-width: 6px;
z-index: -1;
}
#nav ul:before {
top: -10px;
left: 0px;
border-color: transparent #221712 #221712 transparent;
}
#nav ul:after {
top: -8px;
right: 0;
border-color: transparent transparent #221712 #221712;
}
#nav li {
float: left;
font-weight: bold;
text-shadow: 0 1px 2px rgba(0,0,0,.2);
text-align: center;
width: 104px;
margin-right: 1px;
box-shadow: 0 0 0 1px rgba(97,97,97,1) inset;
background-image: -webkit-linear-gradient(top,#4b4b4b,#262626);
background-image: -moz-linear-gradient(top,#4b4b4b,#262626);
background-image: -o-linear-gradient(top,#4b4b4b,#262626);
background-image: -ms-linear-gradient(top,#4b4b4b,#262626);
background-image: linear-gradient(top,#4b4b4b,#262626);
}
#nav li:first-child {
position: relative;
width: 54px;
border-radius: 3px 0 0 3px;
}
#nav li:first-child:after {
position: absolute;
top: 0;
left: 50%;
margin-left: -10px;
display: block;
font-family: 'icomoon';
speak: none;
font-weight: normal;
-webkit-font-smoothing: antialiased;
content: "\22";
color: #121212;
text-shadow: 0 -1px 0 #0e0e0e,0 1px 0 #3a3a3a;
font-size: 16px;
}
#nav li:last-child {
width: 10px;
margin-right: 0;
border-radius: 0 3px 3px 0;
}
#nav li a {
color: #fff;
display: block;
}
#nav li a:hover {
text-decoration: none;
box-shadow: 0 0 0 1px rgba(200,125,25,1) inset;
background-image: -webkit-linear-gradient(top,#a65a12,#7e3106);
background-image: -moz-linear-gradient(top,#a65a12,#7e3106);
background-image: -o-linear-gradient(top,#a65a12,#7e3106);
background-image: -ms-linear-gradient(top,#a65a12,#7e3106);
background-image: linear-gradient(top,#a65a12,#7e3106);
}
#nav li a:active,
#nav li a.active {
color: #e6c35c;
box-shadow: 0 0 0 1px rgba(92,92,92,.8) inset;
background-image: -webkit-linear-gradient(top,#070707,#252525);
background-image: -moz-linear-gradient(top,#070707,#252525);
background-image: -o-linear-gradient(top,#070707,#252525);
background-image: -ms-linear-gradient(top,#070707,#252525);
background-image: linear-gradient(top,#070707,#252525);
}
@font-face {
font-family: 'icomoon';
src: url('fonts/icomoon.eot');
src: url('fonts/icomoon.eot?#iefix') format('embedded-opentype'), url('fonts/icomoon.svg#icomoon') format('svg'), url('fonts/icomoon.woff') format('woff'), url('fonts/icomoon.ttf') format('truetype');
font-weight: normal;
font-style: normal;
}
</style>
<script>
window.onload = function () {
var oNav = document.getElementById('nav');
var aLi = oNav.getElementsByTagName('a');
for (var i = aLi.length; i--;) {
aLi[i].onclick = function () {
for (var i = aLi.length; i--;) {
aLi[i].className = '';
}
this.className = 'active';
}
}
}
</script>
</head>
<body>
<div class="page">
<header id="header">
<hgrounp class="white blank">
<h1></h1>
<h2><h2>
</hgrounp>
</header>
<section class="demo">
<nav id="nav">
<ul class="clearfix">
<li> </li>
<li><a href="#" class="active">标题</a></li>
<li><a href="#">CSS3</a></li>
<li><a href="#">Demo</a></li>
<li><a href="#">Resources</a></li>
<li><a href="#">Rnippet</a></li>
<li><a href="#">Tutorial</a></li>
<li><a href="#">Blog</a></li>
<li> </li>
</ul>
</nav>
</section>
</div>
</body>
</html>
CSS代码(zzsc.css):
@charset "utf-8";@import url("http://www.w3cplus.com/download/reset.css");/* ------------------------------------------------- * common * -------------------------------------------------*/
.page{text-align:left;padding-top:40px;}
.wrap_top_nav{background-color:#333;box-shadow:0 1px 3px rgba(0,0,0,0.25),0 -1px 0 rgba(0,0,0,0.1) inset;height:40px;}
#top_nav{width:1000px;margin:0 auto;position:relative;}
#top_nav a{font-size:16px;line-height:40px;float:left;margin-right:20px;color:#999;text-decoration:none;}
#top_nav a:hover{color:#fff;}
#top_nav li:nth-child(1) a{background-image:url(http://www.w3cplus.com/sites/all/themes/marvin/logo.png);background-position:0 -12px;background-repeat:no-repeat;background-size:68px 60px;padding-left:74px;color:#fff;width:74px;overflow:hidden;}
#read{position:absolute;right:0;top:0;font-family:'����';}
#header{text-align:center;}
#header .white{color:#fff;}
#header .blank{color:#444;}
#header h1{font-size:24px;}
#header h2{font-weight:normal;}
#ad_w3cplus{width:750px;margin:100px auto;text-align:center;}
#ad_w3cplus .grid-ad{float:left;}