@keyframes box { 0% { position: absolute; top: 0; left: 0; background: red; } 25% { position:absolute; top: calc(100% - 100px); left: 0; background: blue; } 50% { position: absolute; top: calc(100% - 100px); left: calc(100% - 100px); background: green; } 75% { position: absolute; top: 0; left: calc(100% - 100px); background: yellow; } 100% { position: absolute; top: 0; left: 0; background: red; } } body { margin: 0; } html { box-sizing: border-box; } .cards { background: #0d5825; height: 500px; width: auto; } .blockquote { font-size: 25px; text-align: center; color: white; position: relative; top: 10px; } .card1 { height: 200px; width: 150px; position: absolute; top: 50%; left: 53%; transform: translate(-47%, -50%) rotate(8deg); z-index: 3; } .card2 { height: 200px; width: 150px; position: absolute; top: 48%; left: 51%; transform: translate(-49%, -52%) rotate(-8deg); z-index: 2; } .card3 { height: 200px; width: 150px; position: absolute; top: 47%; left: 48%; transform: translate(-52%, -53%) rotate(-20deg); } .card1:hover { transition: transform .4s ease-in-out; transform: translate(-47%, -60%) rotate(8deg); } .card2:hover { transition: transform .4s ease-in-out; transform: translate(-49%, -62%) rotate(-8deg); } .card3:hover { transition: transform .4s ease-in-out; transform: translate(-52%, -63%) rotate(-20deg); } /* Task 2 */ .task2 { height: 300px; width: 300px; } .pink { height: 100px; width: 100px; background-color: pink; position: relative; top: 10px; left: 10px; z-index: 1; } .blue { height: 100px; width: 100px; background-color: blue; position: relative; top: -20px; left: 70px; z-index: 2; } .lightgreen { height: 100px; width: 100px; background-color: lightgreen; position: relative; top: -55px; left: 130px; z-index: 1; } /* Task 3 */ .menu { height: 400px; width: 200px; position: relative; transform: translateX(-160px); background-color: gray; } .menu:hover { transition: all .9s linear; transform: translateX(0px); } .menu:hover #vertical { transition: all .9s linear; opacity: 0; } .menu-list { position: relative; top: 100px; } #vertical { font-size: 20px; color: white; writing-mode: vertical-lr; position: relative; top: 10px; left: 10px; float: right; } .list-item { margin-top: 10px; margin-bottom: 10px; } .menu a { text-decoration: none; } .menu-items li { list-style: none; } .menu-items a { color: white; } .links:hover { transition: all .3s ease-in; color: orange; } /* Task 4 */ .anim-holder { width: 300px; height: 300px; position: relative; } .anim-box { width: 100px; height: 100px; position: absolute; top: 0; left: 0; background: red; animation: box 4s linear infinite; }