My animated div gets knocked up, not backwards during animation

I created a basic div with a heading and a paragraph inside it, and when I do a multi-stage animation, the box pops up instead of going back. This makes him look very silly and strange. You can view my bug at https://jsfiddle.net/yajuy8qy/ . Code:

<div class="enlarge">
    <h1 class="title">Welcome!</h1>
    <p>Zach</p>
    </div>
<script>
$(document).ready(function() {
$(".enlarge").animate({minHeight: '500px'}, "slow");
$(".enlarge").animate({width: '80%'}, "slow");
}); 
</script>
<style>
.enlarge {
height: 500px;
width: 50%;
background-color: #2098D1;
align-items: center;
align-content: center;
border-radius: 15px;
position: relative;
margin: 10px auto;
}
</style>

      

Thank!

+3


source to share


1 answer


It seems that the problem is with the default add-on. Try to set padding on div (even 1px appears to fix the crash).



.enlarge{
    padding: 1px;
}

      

+1


source







All Articles