日期:2014-05-16  浏览次数:20411 次

怎样保持标签位置不动
请教一下:
我想在页面上放一个div或者其他的标签或者用JS创建一个div,我想实现在向下拉页面滚动条的时候,这个div的位置保持不动,应该怎么做?   谢谢!

------解决方案--------------------
window.onload = function ()
{
window.onscroll = function ()
{
document.getElementById( "p ").style.top = document.body.scrollTop + "px ";
}
}
<div id= "p " style= " position:absolute ">
this is fixed content on top
</div>