<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="jquery183.min.js"></script>
<style>
ul,li,a,body,div{
margin:0px;
}
#nav li{
width:18%;
border:1px solid blue;
height:50px;
line-height:50px;
list-style:none;
text-align:center;
float:left;
}
.top_jt{
width:100px;
height:50px;
border:1px solid green;
text-align:center;
line-height:50px;
position: fixed;
top:800px;
left:1600px;
z-index:1000;
box-shadow: 1px 1px 10px #666;
}
.dingyi{
position: fixed;
top:0px;
z-index:1000;
box-shadow: 1px 1px 10px #666;
}
</style>
</head>
<body>
<div class="z_daohang" style="width:100%;height:60px;background: #fff;margin: 0 auto;margin-top:20px;">
<div class="z_daohang2" style="width:100%;">
<ul style="width:100%;" id="nav">
<li>
<a href="#AA">AA</a>
</li>
<li>
<a href="#BB">BB</a>
</li>
<li>
<a href="#CC">CC</a>
</li>
<li>
<a href="#DD">DD</a>
</li>
<li>
<a href="#EE">EE</a>
</li>
</ul>
</div>
</div>
<div class="container" >
<div class="content">
<div id="AA" style="position:relative;">
<a name="AA" id="AA" style=" position:absolute;top:-50px;"> </a>
</div>
<div style="margin-top:20px;">
<a > </a>
</div>
<div class="service_scope" style="height:600px;background-color:red;">
AAAAAAAAA
</div>
<div id="BB" style="position:relative;">
<a name="BB" id="BB" style=" position:absolute;top:-50px;"> </a>
</div>
<div style="margin-top:20px;">
<a > </a>
</div>
<div class="service_scope" style="height:600px;background-color:blue;">
BBBBBBBB
</div>
<div id="CC" style="position:relative;">
<a name="CC" id="CC" style=" position:absolute;top:-50px;"> </a>
</div>
<div style="margin-top:20px;">
<a > </a>
</div>
<div class="service_scope" style="height:600px;background-color:green;">
CCCCCCCC
</div>
<div id="DD" style="position:relative;">
<a name="DD" id="DD" style=" position:absolute;top:-50px;"> </a>
</div>
<div style="margin-top:20px;">
<a > </a>
</div>
<div class="service_scope" style="height:600px;background-color:#ccc;">
DDDDDDDD
</div>
<div id="EE" style="position:relative;">
<a name="EE" id="EE" style=" position:absolute;top:-50px;"> </a>
</div>
<div style="margin-top:20px;">
<a > </a>
</div>
<div class="service_cooperation" style="height:600px;background-color:#DEDEDE;">
EEEEEEEEEE
</div>
</div>
</div>
<!--回到顶部-->
<a href="javascript:;" class="top_jt" >↑回到顶部</a>
<script type="text/javascript">
$(function(){
$(window).scroll(function(){//滚动事件
var top=$(this).scrollTop()
if(top>=400){
$(".top_jt").fadeIn(); //回到顶部按钮显示效果
}else{
$(".top_jt").fadeOut(); //回到顶部按钮显示效果
}
if(top>=30){
$(".z_daohang").addClass("dingyi") //导航定位效果
}else{
$(".z_daohang").removeClass("dingyi") //导航定位效果
}
$(".top_jt").click(function(){//回到顶部按钮点击事件
$("html,body").stop().animate({scrollTop:0})
})
})
})
</script>
<!--锚链接-->
<script type="text/javascript">
$(function(){
$('a[href*=#]').click(function() {//锚链接主要在点击的href的ID和需要显示的DIV,A,ID,NAME,一致
if (location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '') && location.hostname == this.hostname) {
var $target = $(this.hash);
$target = $target.length && $target || $('[name=' + this.hash.slice(1) + ']');
if ($target.length) {
var targetOffset = $target.offset().top;
$('html,body').animate({
scrollTop: targetOffset
},
500);
return false;
}
}
});
});
</script>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="jquery183.min.js"></script>
<style>
ul,li,a,body,div{
margin:0px;
}
#nav li{
width:18%;
border:1px solid blue;
height:50px;
line-height:50px;
list-style:none;
text-align:center;
float:left;
}
.top_jt{
width:100px;
height:50px;
border:1px solid green;
text-align:center;
line-height:50px;
position: fixed;
top:800px;
left:1600px;
z-index:1000;
box-shadow: 1px 1px 10px #666;
}
.dingyi{
position: fixed;
top:0px;
z-index:1000;
box-shadow: 1px 1px 10px #666;
}
</style>
</head>
<body>
<div class="z_daohang" style="width:100%;height:60px;background: #fff;margin: 0 auto;margin-top:20px;">
<div class="z_daohang2" style="width:100%;">
<ul style="width:100%;" id="nav">
<li>
<a href="#AA">AA</a>
</li>
<li>
<a href="#BB">BB</a>
</li>
<li>
<a href="#CC">CC</a>
</li>
<li>
<a href="#DD">DD</a>
</li>
<li>
<a href="#EE">EE</a>
</li>
</ul>
</div>
</div>
<div class="container" >
<div class="content">
<div id="AA" style="position:relative;">
<a name="AA" id="AA" style=" position:absolute;top:-50px;"> </a>
</div>
<div style="margin-top:20px;">
<a > </a>
</div>
<div class="service_scope" style="height:600px;background-color:red;">
AAAAAAAAA
</div>
<div id="BB" style="position:relative;">
<a name="BB" id="BB" style=" position:absolute;top:-50px;"> </a>
</div>
<div style="margin-top:20px;">
<a > </a>
</div>
<div class="service_scope" style="height:600px;background-color:blue;">
BBBBBBBB
</div>
<div id="CC" style="position:relative;">
<a name="CC" id="CC" style=" position:absolute;top:-50px;"> </a>
</div>
<div style="margin-top:20px;">
<a > </a>
</div>
<div class="service_scope" style="height:600px;background-color:green;">
CCCCCCCC
</div>
<div id="DD" style="position:relative;">
<a name="DD" id="DD" style=" position:absolute;top:-50px;"> </a>
</div>
<div style="margin-top:20px;">
<a > </a>
</div>
<div class="service_scope" style="height:600px;background-color:#ccc;">
DDDDDDDD
</div>
<div id="EE" style="position:relative;">
<a name="EE" id="EE" style=" position:absolute;top:-50px;"> </a>
</div>
<div style="margin-top:20px;">
<a > </a>
</div>
<div class="service_cooperation" style="height:600px;background-color:#DEDEDE;">
EEEEEEEEEE
</div>
</div>
</div>
<!--回到顶部-->
<a href="javascript:;" class="top_jt" >↑回到顶部</a>
<script type="text/javascript">
$(function(){
$(window).scroll(function(){//滚动事件
var top=$(this).scrollTop()
if(top>=400){
$(".top_jt").fadeIn(); //回到顶部按钮显示效果
}else{
$(".top_jt").fadeOut(); //回到顶部按钮显示效果
}
if(top>=30){
$(".z_daohang").addClass("dingyi") //导航定位效果
}else{
$(".z_daohang").removeClass("dingyi") //导航定位效果
}
$(".top_jt").click(function(){//回到顶部按钮点击事件
$("html,body").stop().animate({scrollTop:0})
})
})
})
</script>
<!--锚链接-->
<script type="text/javascript">
$(function(){
$('a[href*=#]').click(function() {//锚链接主要在点击的href的ID和需要显示的DIV,A,ID,NAME,一致
if (location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '') && location.hostname == this.hostname) {
var $target = $(this.hash);
$target = $target.length && $target || $('[name=' + this.hash.slice(1) + ']');
if ($target.length) {
var targetOffset = $target.offset().top;
$('html,body').animate({
scrollTop: targetOffset
},
500);
return false;
}
}
});
});
</script>
</body>
</html>