jQuery:animate conundrum

时光总嘲笑我的痴心妄想 提交于 2019-12-11 23:21:38

问题


I am having jQuery animation issues...

I have a footer with a hidden div on top of it. When someone clicks a button near the header, the div should animate UP. Sort of like sliding up, like you're pulling a manila folder out of a drawer. (Not the normal slide up where the bottom of the div slides up to the top.)

I found this piece of code that is kind of what I want, however, it's moving the baseline (footer).

.featureBox{width:182px;
    height:150px;
    position:relative;
    border:1px solid red;
}

$('.featureBox').hover(function()  {
    $(this).animate({top:'-320px', height:'540px'},"slow");
},
function() {
    $(this).animate({top:'0px', height:'150px'},"slow");
})

When mousing over the red div box, you'll see that the div below it pushes down. How do I get it to just animate up or grow up? (He-he. Sorry. Just thought of mom yelling at me).


回答1:


Here is a page working the way I think you want. I think the main problem was the the expanding div needs to be inside a div that has a height. Here is a page with the expaning div covering other content when it expands.

Check out the code for the Wordpress Sexybookmarks plugin for a good example of this kind of trick.




回答2:


I'm guessing your fix is one of these two things:

  1. Change position:relative to position:absolute
  2. You don't want to actually move .featureBox but rather another element inside of .featureBox (probably a DIV)


来源:https://stackoverflow.com/questions/1647462/jqueryanimate-conundrum

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!