怎样使<div>做的层不随滚动条的移动而移动

不用frameset解决,例如:我想使 www.csdn.net 中“首 页 ¦ 综 合 ¦ 技 术 ¦ 论 坛 ¦ 人 才 ¦ 商 城 ¦ 大本营 ¦《程序员》 ¦ 软 件”以上部分始终显示,不管下面内容有多少,自始至终我都能看到,而不滚动到上边去。

---------------------------------------------------------------

 1<script language="JavaScript">   
 2speed=200;   
 3pageheight=0;   
 4function KB_keepItInIE(theName,theWantTop,theWantLeft) {   
 5theRealTop=parseInt(document.body.scrollTop)   
 6theTrueTop=theWantTop+theRealTop   
 7document.all[theName].style.top=theTrueTop   
 8theRealLeft=parseInt(document.body.scrollLeft)   
 9theTrueLeft=theWantLeft+theRealLeft   
10document.all[theName].style.left=theTrueLeft   
11}   
12  
13setInterval('KB_keepItInIE("KBStatic",0,0)',1)   
14  
15</script>
1<body>
2<script>   
3for(i=100; i<140; i++){   
4document.write("◇◇"+i+"◇◇<br>")   
5}   
6</script>
7<div id="KBStatic" style="position:absolute; left:3px; top:0px; width:553px; height:70px; z-index:25">   
8********************************************************************************</div>
9</body>

---------------------------------------------------------------

用dreamwear4 的一个插件:Nirvana Floating Layer
(若找不到,可发邮件向我索要:night_[email protected])
---------------------------------------------------------------

http://www.blueidea.com/bbs/newsdetail.asp?id=418813

http://www.blueidea.com/bbs/newsdetail.asp?id=434955
---------------------------------------------------------------

刚编的,你试试可以吗?

1<div id="style1" style="position: absolute; left: 823; top: 456; width: 163; height: 57">   
2你看,我自岿然不动   
3</div>
 1<script>   
 2x0=parseInt(style1.style.left);   
 3y0=parseInt(style1.style.top);   
 4  
 5function doDiv(){   
 6y=document.body.scrollTop;   
 7x=document.body.scrollLeft;   
 8style1.style.top=y0+y;   
 9style1.style.left=x0+x;   
10}   
11</script>

---------------------------------------------------------------

1<div id="style1" style="background:green;position: absolute; left: 0; top: 0; width: 100%; height: 20px">   
2你看,你看,月亮偷偷地在改变   
3</div>
 1<script>   
 2x0=parseInt(style1.style.left);   
 3y0=parseInt(style1.style.top);   
 4  
 5  
 6function window.onscroll(){   
 7y=document.body.scrollTop;   
 8x=document.body.scrollLeft;   
 9style1.style.top=y0+y;   
10style1.style.left=x0+x;   
11}   
12  
13  
14</script>
 1<body magin="0" rightmagin="0">
 2<table style="width:100%;magin=0">
 3<tr style="20px"><td>
 4<tr><td>
 5<script>   
 6for(i=100; i<140; i++){   
 7document.write("◇◇"+i+"◇◇<br>")   
 8}   
 9</script>
10</td></tr></td></tr></table>
11</body>
Published At
Categories with Web编程
comments powered by Disqus