<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>css3渐变头部导航 - 网页模板</title>
</head>
<div id="navi">
<div id="menu" class="default">
<ul>
<li><a href="#">首页</a></li>
<li><a href="#">jquery</a></li>
<li><a href="#">设计</a></li>
<li><a href="#">flex</a></li>
<li><a href="#">air</a></li>
<li><a href="#">ajax</a></li>
<li><a href="#">html5</a></li>
<li><a href="#">css3</a></li>
<li><a href="#">WordPress</a></li>
</ul>
</div><!-- close menu -->
</div><!-- close navi -->
<div id="height">
</div>
<style>#navi {
height: 50px;
margin-top: 50px;
font-size:14px;
}
#height {
height:500px
}
#menu {
/*背景*/
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#8AB9EB), color-stop(40%,#5C9DDC), color-stop(100%,#2374C5));
background: -moz-linear-gradient(top, #8AB9EB, #5C9DDC, #2374C5);
/*圆角*/
border-radius: 5px;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
line-height: 50px;
text-align: center;
margin: 0 auto;
padding: 0;
}
ul {
padding: 0;
}
ul li {
list-style-type: none;
display: inline;
margin-right: 15px;
}
ul li a {
color: #fff;
text-decoration: none;
/*文字阴影*/
text-shadow: 1px 1px 1px #000;
padding: 6px 12px;
/*圆角*/
border-radius: 5px;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
-webkit-transition-property: color, background;
-webkit-transition-duration: 0.5s, 0.5s;
}
ul li a:hover {
background:#FFC;
color:#333;
-webkit-transition-property: color, background;
-webkit-transition-duration: 0.5s, 0.5s;
}
.default {
width: 850px;
height: 50px;
box-shadow: 0 5px 20px #888;
-webkit-box-shadow: 0 5px 20px #888;
-moz-box-shadow: 0 5px 20px #888;
}
.fixed {
position: fixed;
top: -5px;
left: 0;
width: 100%;
box-shadow: 0 0 40px #222;
-webkit-box-shadow: 0 0 40px #222;
-moz-box-shadow: 0 0 40px #222;
}</style>
<script>$(function(){
var menu = $('#menu'),
pos = menu.offset();
$(window).scroll(function(){
if($(this).scrollTop() > pos.top+menu.height() && menu.hasClass('default')){
menu.fadeOut('fast', function(){
$(this).removeClass('default').addClass('fixed').fadeIn('fast');
});
} else if($(this).scrollTop() <= pos.top && menu.hasClass('fixed')){
menu.fadeOut('fast', function(){
$(this).removeClass('fixed').addClass('default').fadeIn('fast');
});
}
});
})</script>
<div style="text-align:center;clear:both">
<p>适用浏览器:FireFox、Chrome、傲游、搜狗. 不支持IE8、360、Safari、Opera、世界之窗。</p>
<p>来源:<a href="http://runjs.cn/" target="_blank">runjs</a></p>
</div>
</body>
</html>