Source codes:
<!DOCTYPE html>
<html>
<head>
<meta charset=”utf-8″>
<meta name=”viewport” content=”width=device-width, initial-scale=1″>
<title> </title>
<style type=”text/css”>
body{
padding: 0;
margin: 0;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
background: black;
overflow: hidden;
}
.sky{
position: relative;
width: 100%;
height: 100%;
}
.moon{
position: absolute;
top: 20%;
left: 50%;
transform: translateX(-50%);
width: 120px;
height: 120px;
background: radial-gradient(circle at 40% 40%, #fff 60%, #f5f5f5 90%);
border-radius: 50%;
animation: moonAnimation 10s infinite linear;
}
.moon:after{
content: “”;
position: absolute;
top: 0;
left: 25px;
width: 100px;
height: 100px;
background: #000814;
border-radius: 50%;
}
.star{
position: absolute;
width: 6px;
height: 6px;
background: orange;
border-radius: 50%;
position: 0;
animation: starAnimation 3s infinite ease-in-out;
}
.star:nth-child(1){
top: 20%;
left: 30%;
animation-delay: 0.5s;
}
.star:nth-child(2){
top: 25%;
left: 70%;
animation-delay: 1s;
}
.star:nth-child(3){
top: 50%;
left: 20%;
animation-delay: 1.5s;
}
.star:nth-child(4){
top: 70%;
left: 80%;
animation-delay: 2s;
}
.star:nth-child(5){
top: 85%;
left: 50%;
animation-delay: 2.5s;
}
.star:nth-child(6){
top: 65%;
left: 35%;
animation-delay: 3s;
}
.star:nth-child(7){
top: 72%;
left: 77%;
animation-delay: 3.5s;
}
.star:nth-child(8){
top: 43%;
left: 83%;
animation-delay: 4s;
}
.star:nth-child(9){
top: 63%;
left: 23%;
animation-delay: 4.5s;
}
@keyframes moonAnimation{
0%{
transform: translateX(-50%) translateY(0);
}
50%{
transform: translateX(-50%) translateY(-30%);
}
100%{
transform: translateX(-50%) translateY(0);
}
}
@keyframes starAnimation{
0%, 100%{
opacity: 0;
transform: scale(0.8);
}
50%{
opacity: 1;
transform: scale(1.2);
}
}
</style>
</head>
<body>
<div class=”sky”>
<div class=”moon”></div>
<div class=”star”></div>
<div class=”star”></div>
<div class=”star”></div>
<div class=”star”></div>
<div class=”star”></div>
<div class=”star”></div>
<div class=”star”></div>
<div class=”star”></div>
</div>
</body>
</html>