jquery fadein() with movement

流过昼夜 提交于 2019-12-12 15:49:41

问题


The following is the code that control two layers which are textlayer and text. After textlayer display then the text display,

<div id="textlayer" style="width:500px; height:500px; background-color:#FFFFFF;filter:alpha(opacity=70);opacity:0.8; position:absolute;left:250;top:150;display:none;">
    <div id="text" style="display:none; padding-top:300px">
    </div>
</div>

    function div2() {
        for (i=0;i<displaymax;i++) {
        $('#span'+i).fadeOut('slow');
        }
        $('#textlayer').fadeIn('slow', function () {
            $('#text').fadeIn(3000);
        });
    }

but i want that the text $('#text') fadein with movement that is from bottom to the top, how do i add the animation to the above code?


回答1:


Is this the effect you are looking for?

http://jsfiddle.net/5agg2/

Without the colors, of course. It fades in the main div, then fades and moves from bottom to top the text div.

Script

$('#textlayer').fadeIn('slow', function () {
   $('#text').animate({'opacity': 'show', 'paddingTop': 0}, 2000);
});

Markup

<div id="textlayer" style="width:500px; height:500px; background-color:#00FFFF;filter:alpha(opacity=70);opacity:0.8;position:absolute;left:250;top:150;display:none;overflow:hidden;">
    <div id="text" style="display:none; background-color:Red; padding-top:900px">
        Test Text
    </div>
</div>

NOTE: I added padding-top:900px to the markup for the text div to move it outside of the containing div and I also added overflow:hidden; to the container.




回答2:


get rid of fadeIn, just use animate

$('#text').animate({'opacity': 'show', 'paddingTop': 0});


来源:https://stackoverflow.com/questions/8845588/jquery-fadein-with-movement

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