I want to make elements that are placed together explode out from each other by increasing the margin on each of them with a CSS animation. The problem I have is that they end up pushing against the top of the container instead of going above the top. Is there any way to just make them expand outwards? You can see what I've done so far in this example. https://jsfiddle.net/liquidmetalrob/kozbpct1/2/
$('#start').click(function() {
$('.abc').addClass('move')
})
#page {
height: 200px;
width: 200px;
background: lightgrey;
}
.abc {
color: red;
padding: 10px;
background: black;
width: 30px;
}
.move {
animation: move 0.6s cubic-bezier(1, 0, 1, 1);
-webkit-animation-fill-mode: forwards;
animation-fill-mode: forwards;
}
@keyframes move {
from {
margin: 0px;
}
to {
margin: 50px;
}
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<html>
<body>
<div id=page>
<div class=abc>
ABC
</div>
<div class=abc>
ABC
</div>
<div class=abc>
ABC
</div>
<div class=abc>
ABC
</div>
<div class=abc>
ABC
</div>
</div>
<button id=start>
Start
</button>
</body>
</html>