css-animation-direction
HTML
<div class="box red top-down">
</div>
<div class="box blue bottom-up">
HelloHi
</div>
<div class="box green left-right">
</div>
<div class="box yellow right-left">
</div>
CSS
.box{width:50px;height:50px;background:#ff5722;margin:10px auto;border-radius:50%;position:relative}
.red{background:#f44336}
.blue{background:#00bcd4}
.green{background:#8bc34a}
.yellow{background:#ffc107}
@keyframes topdown{0%{top:0}100%{top:300px}}
@keyframes bottomup{0%{bottom:0}100%{bottom:300px}}
@keyframes toright{0%{left:0}100%{left:300px}}
@keyframes toleft{0%{right:0}100%{right:300px}}
.top-down{animation:topdown 5s ease-in-out 5 alternate}
.bottom-up{animation:bottomup 5s ease-in-out 5 alternate}
.left-right{animation:toright 5s ease-in-out 5 alternate}
.right-left{animation:toleft 5s ease-in-out 5 alternate}