有人可以幫我在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