<!DOCTYPE html>
<title>Example</title>
<style>
div {
width: 200px;
padding: 20px;
text-align: center;
font: 24px sans-serif;
color: white;
position: absolute;
}
.box1 {
background: yellowgreen;
top: 0px;
left: 0px;
z-index: 1;
animation: myAnimation 1s ease 1s 5 alternate forwards;
.box2 {
background: gold;
top: 20px;
left: 20px;
z-index: 2;
@keyframes myAnimation {
100% {
z-index: 3;
</style>
<div class="box1">Box 1 (animated)</div>
<div class="box2">Box 2</div>