0

How do I have to set css position to animate box(in) that is in the box(out) which is not equal to box(in) height, from down to up.

What I am trying with animating is:

$('#box-out').hover(function(){
    $('#box-in').animate({height: '400px'},2000);
});

It expands downwards as hover right? I just want it to expand upwards. To be able to do that I have to set push it on bottom of box(out).

How do I do that? Please check: http://jsfiddle.net/DxEMT/

4

4 回答 4

2

绝对位置#box-in inside #box-out with bottom: 0; 并给 #box-outposition-relative 就可以了。

#box-out{
   width:300px; 
   height:400px; 
   border:1px solid black; 
   position: relative;
} 
#box-in{
   float:left; 
   width:300px; 
   height:100px; 
   background:red; 
   position:absolute;
   bottom:0px;
} 

其余的与您现有的代码相同。

工作示例:http: //jsfiddle.net/DxEMT/2/

于 2013-08-11T13:19:02.697 回答
1

尝试

#box-out{
    width:300px; 
    height:400px; 
    border:1px solid black; 
    position: relative;
} 
#box-in{
    width:300px; 
    height:100px; 
    background:red; 
    position:absolute;
    bottom:0;
} 

演示:小提琴

于 2013-08-11T13:13:17.617 回答
0

尝试绝对位置.. LIVE DEMO

#box-out
{
    width:300px;
    height:400px;
    border:1px solid black;
    position: relative;
} 
#box-in
{
    width:300px;
    height:100px;
    background:red;
    position:absolute;
    bottom:0;
} 
于 2013-08-11T13:28:29.637 回答
0
$('#box-out').hover(function(){
    $('#box-in').animate({
        height: '-400px'
    },2000);


});

通过反转高度使其向上扩展?

于 2013-08-11T13:12:36.453 回答