【发布时间】:2013-02-27 15:35:53
【问题描述】:
我正在开发一个 css jquery 菜单。我有一个像http://jsfiddle.net/A6rUG/ 这样的代码,我试图向下而不是向上设置动画。 代码是 var slideNav = (function() {
var spanHeight,
nav = $('#nav'),
lis = $('li', nav),
anchors = $('a', lis).css('padding', 0);
$.each(anchors, function() {
var a = $(this),
val = a.text();
a.html('<span>' + val + '</span> <span>' + val + '</span>')
.parent('li')
.height(a.children('span:first').outerHeight())
.end()
.children('span:first')
.css('marginTop', 0) // strange for IE
});
spanHeight = lis.eq(0).height();
lis.hover(function() {
$(this).find('span:first').animate({
marginTop : -56
}, { duration: 200, queue : false });
}, function() {
$(this).find('span:first').animate({
marginTop : 0
}, { duration: 200, queue: false });
});
})();
更改 marginTop 或 marginBottom 似乎并不能解决问题。有人知道会怎样吗?
【问题讨论】:
-
很高兴它有帮助 - 点击勾选将被感激地接受! =)
-
完成,再次感谢 :)
标签: jquery css menu jquery-animate rollover