JSFiddle - React, Tailwind, and code Playground
HTML
<html>
<body>
<div class="container">
<div class="sun">
</div>
</div>
</body>
</html>
CSS
body {
background: #8DBECC;
}
.container {
position: relative;
height: 100%;
width: 100%;
}
.sun {
position: absolute;
width: 30px;
height: 200px;
animation: x-motion 3s ease-in-out 0s infinite alternate;
}
.sun:before {
content: '';
width: 30px;
height: 30px;
position: absolute;
top: 100%;
background: #F18C3E;
animation: y-motion 3s ease-in-out 0s infinite alternate;
border-radius: 15px;
}
@keyframes x-motion {
0% {
left: 0;
}
100% {
left: calc(100% - 30px);
}
}
@keyframes y-motion {
0%, 100% {
top: 100%;
}
50% {
top: 0%;
}
}