JSFiddle - React, Tailwind, and code Playground

HTML

<div class="slide_background"></div>
<div class="slide_content_element button" id="previous">&lt;</div>
<div class="slide_content_element button" id="next">&gt;</div>

<div class="slide_content_element button" id="toggle"> toggle</div>

CSS

.slide_background {
    position: fixed;
    top: 0;
    left: 0;
    
    width: 100%;
    height: 400px;
}

.slide_content_element {
    position: absolute;
    top: 50%;
}

    .slide_content_element#previous {
        left: 0;
    }

    .slide_content_element#next {
        right: 0;
    }

    .slide_content_element#toggle {
        top: 0;
        left: 20%;                
    }        

.button {
    background: black;
    color: white;
    font-weight: bold;
    
    padding: 5px 10px;
}



.slide_background {
/* blueprint grid backround for better visibility of the effect */
/* @url http://lea.verou.me/css3patterns/#blueprint-grid */ 
background-image: url('http://de.selfhtml.org/css/eigenschaften/anzeige/background2.gif');
}

JavaScript

elasticity = 50; // how long the animation of the second element should be delayed to create the rubber band effect. 

// '0' is supposed to make for no delay, but still adds a tiny but visible lag.
// For a more pronounced version of the effect, see http://beta.tliebig.dyndns.org/jsfiddle-elastic-demo


$('#toggle').toggle( 
    function() {
        $('.slide_background').animate({ 'top': '+=50px' }, 500, 'easeOutBack');
        $('.slide_content_element').delay(elasticity).animate({ 'top': '+=50px' }, 500, 'easeOutBack');
    },
    function() {
        $('.slide_background').animate({ 'top': '-=50px' }, 500, 'easeOutBack');
        $('.slide_content_element').delay(elasticity).animate({ 'top': '-=50px' }, 500, 'easeOutBack');
    });