【发布时间】:2012-01-17 21:06:54
【问题描述】:
我有以下使用 slideUp 和 slideDown 效果的脚本,但在为 DIV 的高度设置动画时无法正常工作:
$(function () {
var myTimer,
myDelay = 500;
$('.slide, .the_menu').hover(function () {
//when either a `img.menu_class` or a `.the_menu` element is hovered over, clear the timeout to hide the menu and slide the menu into view if it already isn't
clearTimeout(myTimer);
$('.the_menu').animate({height:'37px'},'fast', function () { $('.the_menu').stop(true, true).fadeIn('slow'); });
},
function () {
//when either a `img.menu_class` or a `.the_menu` element is hovered out, set a timeout to hide the menu
myTimer = setTimeout(function () {
$('.the_menu').stop(true, true).fadeOut('slow', function () { $('.the_menu').animate({height:'0px'},'fast'); });}, myDelay);
});
});
您可以在this page 上看到它的实际效果。将鼠标悬停在导航栏中的第二个“主页”图像上。
问题在于 DIV 高度上的动画似乎无法正常工作,即没有平滑过渡,而是高度突然变化。
谁能告诉我为什么?
谢谢,
尼克
【问题讨论】:
标签: jquery height jquery-animate