Fade and translate the "position:absolute" element from top to bottom using jquery

user782104

The Class "anim" needs to fade in from top to bottom

HTML code

<div class="col-xs-6" style="position:relative;">
    <img src="<?= site_url('assets/image/right_bg.png'); ?>" style="width:100%; position:absolute; top:0; left:0;">
    <img class="anim" src="<?= site_url('assets/image/right_cover_1-11.png'); ?>">
    <img class="anim" src="<?= site_url('assets/image/right_cover_2-11.png'); ?>">
    <img class="anim" src="<?= site_url('assets/image/right_cover_3-11.png'); ?>">
    <img class="anim" src="<?= site_url('assets/image/right_cover_4-11.png'); ?>">
    <img class="anim" src="<?= site_url('assets/image/right_cover_5-11.png'); ?>">
    <img class="anim" src="<?= site_url('assets/image/right_cover_6-11.png'); ?>">
    <img class="anim" src="<?= site_url('assets/image/right_cover_7-11.png'); ?>">
    <img class="anim" src="<?= site_url('assets/image/right_cover_8-11.png'); ?>">
    <img class="anim" src="<?= site_url('assets/image/right_cover_9-11.png'); ?>">
    <img src="<?= site_url('assets/image/right_bg_mid.png'); ?>" style="width:100%; position:absolute; top:0; left:0;">
</div>

CSS code

.anim {
    display:none;
    width:100%; 
    position:absolute; 
    top:-100px; 
    left:0;
}

I would like to work with show() and top:0px in jquery animation, thanks a lot for helping

Roysh

The CSS way:

Create a costum animation

@keyframes fadein {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* Firefox < 16 */
@-moz-keyframes fadein {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* Safari, Chrome and Opera > 12.1 */
@-webkit-keyframes fadein {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* Internet Explorer */
@-ms-keyframes fadein {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* Opera < 12.1 */
@-o-keyframes fadein {
    from { opacity: 0; }
    to   { opacity: 1; }
}

Then, apply to the divs you want to fade

.anim {
    display:none;
    width:100%; 
    position:absolute; 
    top:-100px; 
    left:0;

-webkit-animation: fadein 2s; /* Safari, Chrome and Opera > 12.1 */
   -moz-animation: fadein 2s; /* Firefox < 16 */
    -ms-animation: fadein 2s; /* Internet Explorer */
     -o-animation: fadein 2s; /* Opera < 12.1 */
        animation: fadein 2s;
}

if you want the divs to fade in from top to bottom, you can give each of the divs a unique class name and then create a selector for each of them with the animation css command (the last five lines in the selector above) . The only thing you change is the argument of the seconds. The top should fade the fastest (suppose 0.2s) and then increase it until the last (all the code here should be in one cssfile)

The jQuery way

Put all the divs in an array and then animate each of the while increasing the delay

$(document).ready(function() {
    $(".anim").each(function(index, value) {
        $(value).fadeTo(index * 1000, 1);

    });
});

While you can play with the fading time (suppose, add index*2000 instead of 1000) Make sure opacity is 0 before fading

Fiddle

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to fade in from bottom to top

From Dev

Android animate my Relative Layout from bottom to Top and Top to Bottom using translate animation on image view click

From Dev

Position:absolute without top/left/bottom/right values

From Dev

HTML/CSS Float Left and Top/Bottom without position absolute/fixed

From Dev

Why is not this element with position absolute and top 0 in the top of its container?

From Dev

Apply position absolute style using JavaScript / jQuery

From Dev

jQuery .on('click') issues when using position absolute

From Dev

How to keep footer on the bottom without affected by position:absolute element

From Dev

Position Absolute and Bottom 0

From Dev

Position Absolute and Bottom 0

From Dev

CSS - Align div in bottom of screen without using position: absolute

From Dev

Is there a way to position divs on top of each other without using position absolute?

From Dev

How can I move a div from top to bottom by using jQuery?

From Dev

How can I move a div from top to bottom by using jQuery?

From Dev

Animate Canvas Fill() From Bottom To Top Using JavaScript / jQuery

From Dev

jquery sliding from top to bottom

From Dev

Prevent position absolute element from sticking inside scrollable div

From Dev

Prevent position absolute element from sticking inside scrollable div

From Dev

Custom element with position absolute

From Dev

iOS 7 navigationbar barTintColor - able to have it fade from top to bottom?

From Dev

iOS 7 navigationbar barTintColor - able to have it fade from top to bottom?

From Dev

How to add !important in position:absolute using jQuery.css() function?

From Dev

jQuery scroll left is not working when using position absolute?

From Dev

How to add !important in position:absolute using jQuery.css() function?

From Dev

Jquery - stop mouse-locked position:absolute from extending page?

From Dev

Fade bottom or top of text in a div

From Dev

Scroll bottom of browser viewport to top of element (jQuery)

From Dev

CSS: Position child indepently from parent without using position:absolute

From Dev

What are the left and top values of an element and its child element if both have position:absolute

Related Related

  1. 1

    How to fade in from bottom to top

  2. 2

    Android animate my Relative Layout from bottom to Top and Top to Bottom using translate animation on image view click

  3. 3

    Position:absolute without top/left/bottom/right values

  4. 4

    HTML/CSS Float Left and Top/Bottom without position absolute/fixed

  5. 5

    Why is not this element with position absolute and top 0 in the top of its container?

  6. 6

    Apply position absolute style using JavaScript / jQuery

  7. 7

    jQuery .on('click') issues when using position absolute

  8. 8

    How to keep footer on the bottom without affected by position:absolute element

  9. 9

    Position Absolute and Bottom 0

  10. 10

    Position Absolute and Bottom 0

  11. 11

    CSS - Align div in bottom of screen without using position: absolute

  12. 12

    Is there a way to position divs on top of each other without using position absolute?

  13. 13

    How can I move a div from top to bottom by using jQuery?

  14. 14

    How can I move a div from top to bottom by using jQuery?

  15. 15

    Animate Canvas Fill() From Bottom To Top Using JavaScript / jQuery

  16. 16

    jquery sliding from top to bottom

  17. 17

    Prevent position absolute element from sticking inside scrollable div

  18. 18

    Prevent position absolute element from sticking inside scrollable div

  19. 19

    Custom element with position absolute

  20. 20

    iOS 7 navigationbar barTintColor - able to have it fade from top to bottom?

  21. 21

    iOS 7 navigationbar barTintColor - able to have it fade from top to bottom?

  22. 22

    How to add !important in position:absolute using jQuery.css() function?

  23. 23

    jQuery scroll left is not working when using position absolute?

  24. 24

    How to add !important in position:absolute using jQuery.css() function?

  25. 25

    Jquery - stop mouse-locked position:absolute from extending page?

  26. 26

    Fade bottom or top of text in a div

  27. 27

    Scroll bottom of browser viewport to top of element (jQuery)

  28. 28

    CSS: Position child indepently from parent without using position:absolute

  29. 29

    What are the left and top values of an element and its child element if both have position:absolute

HotTag

Archive