<!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" />
<title>无标题文档</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
<style type="text/css">
*{
margin:0;
padding:0;
}
div.search_wei{
margin:0 auto;
width:1000px;
position:absolute;
}
div.fixedNav{
position:fixed;
top:-200px;
left:0px;
width:1000;
z-index:100000;
_position:absolute;
_top:expression(eval(document.documentElement.scrollTop));
}
html{
_background:url(about:blank);
}
.search{
width:1000px;
height:40px;
background:#FFF;
border:5px solid #00BCF3;
position:absolute;
top:200px;
left:215px;
}
</style>
<script>
$(function(){
$(window).scroll(function() {
if($(window).scrollTop()>=200){
$(".search_wei").addClass("fixedNav");
}else{
$(".search_wei").removeClass("fixedNav");
}
});});
</script>
</head><body style="height:2000px;">
<div class="search_wei">
<div class="search">
</div>
</div>
</body>
</html>求IE6 的解决方法
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
<style type="text/css">
*{
margin:0;
padding:0;
}
div.search_wei{
margin:0 auto;
width:1000px;
position:absolute;
}
div.fixedNav{
position:fixed;
top:-200px;
left:0px;
width:1000;
z-index:100000;
_position:absolute;
_top:expression(eval(document.documentElement.scrollTop));
}
html{
_background:url(about:blank);
}
.search{
width:1000px;
height:40px;
background:#FFF;
border:5px solid #00BCF3;
position:absolute;
top:200px;
left:215px;
}
</style>
<script>
$(function(){
$(window).scroll(function() {
if($(window).scrollTop()>=200){
$(".search_wei").addClass("fixedNav");
}else{
$(".search_wei").removeClass("fixedNav");
}
});});
</script>
</head><body style="height:2000px;">
<div class="search_wei">
<div class="search">
</div>
</div>
</body>
</html>求IE6 的解决方法
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
<style type="text/css">
*{
margin:0;
padding:0;
}
div.search_wei{
margin:0 auto;
width:1000px;
position:absolute;
}
div.fixedNav{
position:fixed;
top:-200px;
left:0px;
width:1000;
z-index:100000;
_position:absolute;
/*
_top:expression(eval(document.documentElement.scrollTop));
*/
}
html{
_background:url(about:blank);
}
.search{
width:1000px;
height:40px;
background:#FFF;
border:5px solid #00BCF3;
position:absolute;
top:200px;
left:215px;
}
</style>
<!--[if lte IE 6]>
<script> IE6=true </script>
<![endif]--><script>
$(function(){
$(window).scroll(function() {
if($(window).scrollTop()>=200){
$(".search_wei").addClass("fixedNav");
if(window.IE6){
$(".search_wei").css({top: $(window).scrollTop()-200 })
}
}else{
$(".search_wei").removeClass("fixedNav");
}
});
});
</script>
</head><body style="height:2000px;">
<div class="search_wei">
<div class="search">
</div>
</div>
</body>
</html>