JQuery 动画不工作
由于某种原因,我似乎无法让 .animate 正常运行。有人能看出为什么吗?
我正在用这个 一个容器 div...
#valve-menu {
position: absolute;
width: 780px;
top: 200px;
background-color: #9C3;
margin-right: 9px;
margin-left: 10px;
}
然后...
#control-cover{
height: 50px;
width: 180px;
overflow: hidden;
position: absolute;
}
#control{
background-color: #0C9;
height: 200px;
width: 180px;
margin-right: 10px;
position: absolute;
}
我的 Jquery 是这样的,
$(document).ready(function(){
//When mouse rolls over
$("#control-cover").mouseover(function(){
$(this).stop()
.animate({height:'150px'},
{queue:false, duration:600, easing: 'easeOutBounce'})
});
//When mouse is removed
$("#control-cover").mouseout(function(){
$(this).stop()
.animate({height:'50px'},
{queue:false, duration:600, easing: 'easeOutBounce'})
});
});
我想让控件 div 部分隐藏,然后在鼠标悬停时展开。
For some reason I can' t seem to get .animate to function properly. Can anybody see why?
I'm using this
a container div...
#valve-menu {
position: absolute;
width: 780px;
top: 200px;
background-color: #9C3;
margin-right: 9px;
margin-left: 10px;
}
then..
#control-cover{
height: 50px;
width: 180px;
overflow: hidden;
position: absolute;
}
#control{
background-color: #0C9;
height: 200px;
width: 180px;
margin-right: 10px;
position: absolute;
}
My Jquery is this
$(document).ready(function(){
//When mouse rolls over
$("#control-cover").mouseover(function(){
$(this).stop()
.animate({height:'150px'},
{queue:false, duration:600, easing: 'easeOutBounce'})
});
//When mouse is removed
$("#control-cover").mouseout(function(){
$(this).stop()
.animate({height:'50px'},
{queue:false, duration:600, easing: 'easeOutBounce'})
});
});
I want to have the control div partially hidden and then onmouseover expand.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是有效的。如果您不使用 Easing 插件,则默认情况下 jQuery Swing 和 Linear 中只有两个可用:
来自 jQuery 网站 http://api.jquery.com/animate/
This is working. If you're not using an Easing plugin there are only two available by default inside jQuery Swing and Linear:
From jQuery website http://api.jquery.com/animate/
jQuery 中的
$('#control-over')
选择器将在 html 中搜索 id 为control-over
的元素,例如。从您的代码示例来看,您似乎有一个名为
control-over
的 CSS class。两者并不相同。您需要将
id=
属性添加到 html 元素,或者按类名称搜索元素,例如$('.control-over')
。The
$('#control-over')
selector in jQuery will search your html for an element that has an id ofcontrol-over
, e.g.<div id="control-over">
. From your code sample, it looks like you have a CSS class calledcontrol-over
. The two are not the same.You need to either add the
id=
attribute to your html element, or search for the element by class name, like$('.control-over')
.