我希望在用户向下滚动屏幕时有一个跟随我的用户的菜单,但是我的代码看起来不起作用。任何建议:
<html>
<head></head>
<body style="height:2000px;"> <div style="position:fixed;right:0px; width:100px; height:200px; top:100px; background-color:blue;">
</div>
</body>
</html>
答案 0 :(得分:0)
您可以使用JavaScript来修复IE的位置,这是我的代码
<html>
<head>
</head>
<body>
<div style="height:2000px;">
<div id="menu1" style="position:absolute;right:0px; width:100px; height:200px; top:100px; background-color:blue;"> </div>
</div>
<script language="javascript" type="text/javascript">
window.onscroll = updatePosition;
window.onresize = updatePosition;
function getScrollTop()
{
if(typeof pageYOffset != 'undefined')
{
//most browsers except IE before #9
return pageYOffset;
}
else
{
var B = document.body; //IE 'quirks'
var D = document.documentElement; //IE with doctype
D = (D.clientHeight) ? D : B;
return D.scrollTop;
}
}
function updatePosition()
{
document.getElementById("menu1").style.top = getScrollTop()+100;
}
</script>
</body>
</html>
您可以使用jQuery动画进行平滑滚动:)