求解!!!!!! 当滚动条滑到某一部分以后那一部分的横条就停靠在浏览器顶端,例如http://tuan.newegg.com.cn/里“团购筛选”所在横条,求解!!!!!!!!!!!!!!!!!!!!!!!!浏览器js 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 用的是fixed定位,你在ie6下看看这个东东不好使.fixpos{position:fixed!important;top:-11px;width:970px;_position:absolute!important;_left:0!important;_top:expression(documentElement.scrollTop-document.getElementById('header').offsetHeight-25>0?documentElement.scrollTop-document.getElementById('header').offsetHeight-25:0);} <html xmlns="http://www.w3.org/1999/xhtml"><head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>无标题文档</title> <script src="Scripts/jquery-1.9.1.min.js"></script> <style> .box { position: absolute; width: 100px; height: 20px; background: #ccc; } </style></head><body> <div style="height: 200px; background: blue;">1111111111111111111</div> <div class="box" id="box">心随你动</div> <div style="height: 1400px; background: green; margin-top: 40px;"></div> <script> $(function () { $(window).scroll(function () { var top = $(this).scrollTop(); if (top > 200) { var space = $("#box").scrollTop(); $("#box").css("top", space + "px"); var height = document.documentElement.scrollTop + document.body.scrollTop + space; var top1 = parseInt($("#box").css("top")); $("#box").css("top", parseInt(height - top1)); } else { $("#box").css("top", 200); } }); }) </script></body></html> 下面这个好点,上面那个效果是实现 了,但是代码有点乱。<html xmlns="http://www.w3.org/1999/xhtml"><head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>无标题文档</title> <script src="Scripts/jquery-1.9.1.min.js"></script> <style> .box { position: absolute; width: 100px; height: 20px; background: #ccc; } </style></head><body> <div style="height: 200px; background: blue;">1111111111111111111</div> <div class="box" id="box">心随你动</div> <div style="height: 1400px; background: green; margin-top: 40px;"></div> <script> $(function () { $(window).scroll(function () { var top = $(this).scrollTop(); if (top > 200) { $("#box").css("top", 0); $("#box").css("top",top); } else { $("#box").css("top", 200); } }); }) </script></body></html> 3#方法应该可以的,没实现估计是你的jquery路径不对 <html xmlns="http://www.w3.org/1999/xhtml"><head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>无标题文档</title> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> <style> .box { position: absolute; width: 100px; height: 20px; background: #ccc; } </style></head> <body> <div style="height: 200px; background: blue;">1111111111111111111</div> <div class="box" id="box">心随你动</div> <div style="height: 1400px; background: green; margin-top: 40px;"></div> <script> $(function () { $(window).scroll(function () { var top = Math.max($(document.body).scrollTop(), $(document.documentElement).scrollTop()); if (top > 200) { $("#box").css("top",top); } else { $("#box").css("top", 200); } }); }) </script></body></html>可兼容ie 我的IE9为什么不会纠错javascript,是要设置哪里么? js如何清除用户信息 javascript 能否隐藏select 用CSS或js如何实现字体渐渐消失 js分页 优酷网 Extjs做成的表格新插入数据,出现红三角符号,请问玄机在哪,请大侠指点 qiuming0306 () 来看此帖! 打印条码问题 问一个比较有难度的问题 请问怎么样知道一个页面是不是由showmodaldialog打开的 jquery可编辑表格 js大神速度进来问个事。急
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script src="Scripts/jquery-1.9.1.min.js"></script>
<style>
.box
{
position: absolute;
width: 100px;
height: 20px;
background: #ccc;
}
</style>
</head><body>
<div style="height: 200px; background: blue;">1111111111111111111</div> <div class="box" id="box">心随你动</div> <div style="height: 1400px; background: green; margin-top: 40px;"></div>
<script>
$(function () {
$(window).scroll(function () { var top = $(this).scrollTop();
if (top > 200) {
var space = $("#box").scrollTop();
$("#box").css("top", space + "px");
var height = document.documentElement.scrollTop + document.body.scrollTop + space;
var top1 = parseInt($("#box").css("top"));
$("#box").css("top", parseInt(height - top1));
} else {
$("#box").css("top", 200);
}
});
})
</script>
</body>
</html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script src="Scripts/jquery-1.9.1.min.js"></script>
<style>
.box
{
position: absolute;
width: 100px;
height: 20px;
background: #ccc;
}
</style>
</head><body>
<div style="height: 200px; background: blue;">1111111111111111111</div> <div class="box" id="box">心随你动</div> <div style="height: 1400px; background: green; margin-top: 40px;"></div>
<script>
$(function () {
$(window).scroll(function () {
var top = $(this).scrollTop();
if (top > 200) {
$("#box").css("top", 0);
$("#box").css("top",top);
} else {
$("#box").css("top", 200);
}
});
})
</script>
</body>
</html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<style>
.box
{
position: absolute;
width: 100px;
height: 20px;
background: #ccc;
}
</style>
</head>
<body>
<div style="height: 200px; background: blue;">1111111111111111111</div>
<div class="box" id="box">心随你动</div>
<div style="height: 1400px; background: green; margin-top: 40px;"></div>
<script>
$(function () {
$(window).scroll(function () {
var top = Math.max($(document.body).scrollTop(), $(document.documentElement).scrollTop());
if (top > 200) {
$("#box").css("top",top);
} else {
$("#box").css("top", 200);
}
});
})
</script>
</body>
</html>可兼容ie