How can I achieve a sliding effect for two horizontally centered divs, #box1 and #box2, when a button with the class .class is clicked? The desired animation involves moving #box1 to the left and off the screen, while #box2 slides into view from the right. I have seen examples for absolutely positioned divs, but I am curious how to achieve this effect without absolute positioning.
HTML Structure
<div class="button"><a href="#">Slide</a> </div>
<div id="container">
<div id="box1" class="box">Box #1</div>
<div id="box2" class="box">Box #2</div>
</div>
Failed attempt
$(".button").click(function() {
$("#box1").css('margin-left', 0);
$("#box1").css('margin-right', 0);
$("#box1").animate({
left: '150%',
}, 'slow' );
});