使用 Scriptaculous 向上扩展元素
我正在使用 Prototype/Scriptaculous 构建一个小菜单项。
我设置的小测试在菜单项上使用 Effect.Scale 。当您将鼠标悬停在菜单项上时,我希望该项目向上缩放并推动其他元素。
我将 ul.nav 设置为特定高度,但缩放元素似乎绝对定位,因此它从流程中移除并在框外向下缩放。
有办法做到这一点还是我做错了? 这是页面: 已删除,-无效网址 (http://krd/krd-design.net)< /strong>
CSS:
.menuitem {
border: 1px solid black;
width: 90px;
}
.lift {
display: block;
background-color: gray;
width: 90px;
height: 1px;
}
.nav {
border-bottom: 1px solid black;
height: 60px;
}
JavaScript:
$$('.menuitem').each(function(s){
if($(s).down(1).tagName == 'SPAN' && $(s).down(1).className == 'lift') {
var lift = $(s).down(1);
$(s).observe('mouseenter', function() {
new Effect.Scale(lift, 120, {
scaleX: false,
scaleY: true,
scaleContent: false,
scaleMode: { originalHeight: 100 },
scaleFrom: 1
})
});
}
})
谢谢! 富有的
I'm building a little menu item using Prototype/Scriptaculous.
The little test I have setup uses Effect.Scale on a menu item. I'd like the item to scale upward and push the other element up with with it when you hover over the menu item.
I have the ul.nav set to a specific height, but the scaled element seems to be positioned absolutely so its removed from the flow and scales downward outside of the box.
Is there a way to do this or am I going about this wrong?
Here is the page:
DELETED , -invalid URL (http://krd/krd-design.net)
The CSS:
.menuitem {
border: 1px solid black;
width: 90px;
}
.lift {
display: block;
background-color: gray;
width: 90px;
height: 1px;
}
.nav {
border-bottom: 1px solid black;
height: 60px;
}
The javascript:
$('.menuitem').each(function(s){
if($(s).down(1).tagName == 'SPAN' && $(s).down(1).className == 'lift') {
var lift = $(s).down(1);
$(s).observe('mouseenter', function() {
new Effect.Scale(lift, 120, {
scaleX: false,
scaleY: true,
scaleContent: false,
scaleMode: { originalHeight: 100 },
scaleFrom: 1
})
});
}
})
Thanks!
Rich
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我使用 Effect.Morph 总是比 Effect.Scale 更成功。它为您提供了更精细的控制。
I've always has more success with Effect.Morph, than Effect.Scale. It gives you much finer control.