我做了一个静止的层,滚动条上下滚动时保持在静止位置,代码如下:我现在是想把它改成不静止的层,滚动条上下滚动时层也一起滚动。请教大家要怎么改,才能保持不静止<style type="text/css">
.obj{width:222px;height:auto;position:relative; background-color:White }
.dtree{ width:200px;height:auto;border:1px solid #666666;background-color:White}
.btn{ width:18px; height:auto;float:left; position:absolute; right:0; top:0; cursor:pointer;background-color:White}
</style>
<div id="obj" class="obj">
<div id="box" class="dtree">
<div class="btn" id="btn"><script type="text/javascript">
var ig=document.getElementById("obj");
var box=document.getElementById("box");
var btn=document.getElementById("btn");
var w=box.offsetWidth;
var isIE = (document.all) ? true : false;
var isIE6 = isIE && ([/MSIE (\d)\.0/i.exec(navigator.userAgent)][0][1] == 6);
var Bind = function(object, fun) {
return function() {
return fun.apply(object, arguments);
}
}
ig.style.position ="fixed";
ig.style.zIndex='1000';
ig.style.left='0'+"px";
ig.style.top='130'+"px";
if(isIE6){
ig.style.position ="absolute";
ig._fixed = Bind(ig, function(){
ig.style.marginTop = document.documentElement.scrollTop + "px";
ig.style.marginLeft = document.documentElement.scrollLeft + "px";});
ig._fixed()
window.attachEvent("onscroll", ig._fixed);
}
ig.style.left=-w+"px";
</script>
.obj{width:222px;height:auto;position:relative; background-color:White }
.dtree{ width:200px;height:auto;border:1px solid #666666;background-color:White}
.btn{ width:18px; height:auto;float:left; position:absolute; right:0; top:0; cursor:pointer;background-color:White}
</style>
<div id="obj" class="obj">
<div id="box" class="dtree">
<div class="btn" id="btn"><script type="text/javascript">
var ig=document.getElementById("obj");
var box=document.getElementById("box");
var btn=document.getElementById("btn");
var w=box.offsetWidth;
var isIE = (document.all) ? true : false;
var isIE6 = isIE && ([/MSIE (\d)\.0/i.exec(navigator.userAgent)][0][1] == 6);
var Bind = function(object, fun) {
return function() {
return fun.apply(object, arguments);
}
}
ig.style.position ="fixed";
ig.style.zIndex='1000';
ig.style.left='0'+"px";
ig.style.top='130'+"px";
if(isIE6){
ig.style.position ="absolute";
ig._fixed = Bind(ig, function(){
ig.style.marginTop = document.documentElement.scrollTop + "px";
ig.style.marginLeft = document.documentElement.scrollLeft + "px";});
ig._fixed()
window.attachEvent("onscroll", ig._fixed);
}
ig.style.left=-w+"px";
</script>
<div id="obj" class="obj">
<div id="box" class="dtree">
<div class="btn" id="btn">
</div>即obj里包含box和btn.
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript">
window.onload = function() {
if(!window.XMLHttpRequest) {
var qqbar = document.getElementById("qqBar");
qqbar.style.position = "absolute";
window.onscroll = function() {
qqbar.className = qqbar.className;
};
}
}
</script>
<style>
body {
height:2000px;
}
div {
position:fixed;
right:50%;
bottom:50%;
height:60px;
width:200px;
border:1px solid #000;
background-color:#eee;
}
</style>
</head><body>
<div id="qqBar">
</div></body>
</html>