当滑鼠拉滚动条令主页面上下滚动的时候,一个浮动窗口一直挂在屏幕的固定位置,或自动漂到指定位置,如何整?

vnking 2009-01-26 11:45:27
当滑鼠拉滚动条令主页面上下滚动的时候,一个浮动窗口一直挂在屏幕的固定位置,或自动漂到指定位置,如何整?

类似于某些广告窗口!
...全文
228 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
不悲不喜 2009-01-26
  • 打赏
  • 举报
回复
以前做的。给你参考一下。
<!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" />
<style type="text/css">
body {
margin: 0;
padding: 0
} .fixed {
position: fixed;
bottom: 0;
width: 146px;
height: 326px;
left: 160px;
top: 300px;
background-color: slategray;
font-size:10px;
font-family:Verdana;
margin-left: -150px /*为.fixed宽的一半*/;
margin-top: -150px /*为.fixed高的一半*/;
background: #006633;
border:2px solid slategray;
cursor:default;
}
</style>
<!--以下是为了兼容IE6的hack-->
<!--[if IE 6]>
<style type="text/css">
html {
overflow: hidden;
}

body {
height: 100%;
overflow: auto;
} .fixed {
position: absolute;
}
</style>
<![endif]-->
</head>
<body>
<div id="Div1" class="fixed" style='z-index:10002;'>
<div id="div2" style='background-color:slategray;width:140;height:20;color:white;'>
<span id="s1" style='width:110;padding-left:3px;'>测试</span>
</div>
<div id="div3" style='width:140;height:300;background-color:white;line-height:14px;word-break:break-all;padding:3px;'>
<div id="div4">
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="140" height="300" id="test" align="middle">
<param name="allowScriptAccess" value="sameDomain" />
<param name="movie" value="http://d1.sina.com.cn/200804/23/134217_120x180_20k.swf" />
<param name="quality" value="high" /><param name="bgcolor" value="#ffffff" />
<embed src="http://d1.sina.com.cn/200804/23/134217_120x180_20k.swf" quality="high" bgcolor="#ffffff" width="140" height="300" name"=UserList" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
</object>
</div>
</div>
</div>
<table width="100%" border="1">
<script>
for (var i = 0; i < 100; i++) {
document.write("<tr>");
document.write("<td>aaaa</td>");
document.write("<td>aaaa</td>");
document.write("<td>aaaa</td>");
document.write("</tr>");
}
</script>
</table>
</body>
</html>
CutBug 2009-01-26
  • 打赏
  • 举报
回复
<html>
<head>
<script>
function test()
{
document.getElementById("div1").style.top=document.body.scrollTop+100;//100为top:100px
}
</script>
</head>
<body onscroll="test()">
<div id="div1" style="position:absolute;top:100px;border:solid #000 1px;width:100px;height:60px">
广告
</div>
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
<br><br><br><br><br><br><br><br><br><br><br><br>
</body>
</html>

87,915

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧