有人可以帮我在prototypeJS中做一个浮动菜单吗?我发现文档在jQuery中完成,如下所示:net.tutsplus.com/tutorials/html-css-techniques/creating-a-floating-html-menu-using-jquery-and-css/和这里:manos.malihu .gr/jquery-floating-menu,但是找不到prototypeJS的起始位置。PrototypeJS中的浮动菜单
因此,我得到它的工作,sorta。我发现documentation here。这里是我的代码:
<html>
<head>
<title>Prototype examples</title>
<script src="lib/prototype/prototype.js" type="text/javascript"></script>
<script type="text/javascript">
Event.observe(window,'scroll', function(evt){
$('movable').setStyle({ top: 8 + document.viewport.getScrollOffsets().top + 'px' });
});
</script>
<style type="text/css">
#container {
background:#000;
padding:100px 10px 10px;
}
#movable {
position: absolute;
float:left;
width:18.5%;
height: 300px;
background-color: red;
}
#firstDiv {
background:#ccc;
float:right;
height:1200px;
width:80%;
}
.clear-both {clear:both;}
</style>
</head>
<body>
<div id="container">
<div id="movable"> Floating menu</div>
<div id="firstDiv">right</div>
<div class="clear-both"></div>
</div>
</body>
</html>
所以现在我试图得到它,以便当您滚动,所以菜单犯规开始移动,直到滚动向下移动到喜欢100px的垂直或东西它不是波涛汹涌,所以它挂钩到位。
真棒谢谢!我应该使用Effect.ScrollTo进行动画吗? – Aaron 2010-09-19 16:06:19
Effect.ScrollTo仅滚动视口本身,它不会动画元素的位置。看看Effect.Move(http://wiki.github.com/madrobby/scriptaculous/effect-move)。 – 2010-09-20 01:02:41