Sunrise And Sunset Animation Using HTML & CSS?

HTML Code


<html lang="en">
<head>
    <meta charset="UTF-8"></meta>
    <meta content="IE=edge" http-equiv="X-UA-Compatible"></meta>
    <meta content="width=device-width, initial-scale=1.0" name="viewport"></meta>
    <title>Sunrise and Sunset</title>
    <link href="style.css" rel="stylesheet"></link>
</head>
<body>
    <div id="sun"></div>
    <div class="hill"></div>
    <div class="hill"></div>
    <div class="hill"></div>
    <div class="hill"></div>
    <div class="hill"></div>
    <div id="land"></div>
</body>
</html>

CSS Code

*{
    box-sizing: border-box;
    margin: 0;
    padding:0;
}
body{
    background-color: rgb(154,209,253);
    overflow:hidden;
    animation: sky 24s infinite linear;
}
@keyframes sky {
    0%{
        background-color: rgb(63, 116, 129);
    }
    10%{
        background-color: rgb(0, 180, 180);
    }
    50%{
        background-color: skyblue;
    }
    90%{
        background-color: rgb(0, 180, 180);
    }
    100%{
        background-color: rgb(63, 116, 129);

    }
    
}
#land{
    width: 100%;
    height: 20%;
    background-color: #848288;
    position: absolute;
    bottom: 0;
}
.hill{
    width: 40vh;
    height: 40vh;
    background-color: green;
    transform: rotate(45deg);
    position: absolute;
    bottom: -1%;
    border-radius: 5%;
}
.hill:nth-child(2){
    left: 40vh;
}

.hill:nth-child(3){
    left: 80vh;
    bottom:-3%;
}

.hill:nth-child(4){
    left: 120vh;
    bottom:1%;
}

.hill:nth-child(5){
    left: 170vh;
    bottom:3%;
}
#sun{
    width: 20vh;
    height: 20vh;
    background-color: rgb(255, 196, 0);
    border-radius: 50%;
    border: 2px solid red;
    position: absolute;
    right: 15%;
    bottom: 20%;
    animation: sun 24s infinite linear;

}
@keyframes sun {
    0%{
        transform: translate(-10%,-10%);
    }
    10%{
        transform: translate(-15%,-50%);
    }
    20%{
        transform: translate(-50%,-100%);
    }
    30%{
        transform: translate(-100%,-150%);
    }
    40%{
        transform: translate(-200%,-200%);
    }
    50%{
        transform: translate(-300%,-220%);
    }
    60%{
        transform: translate(-400%,-210%);
    }
    70%{
        transform: translate(-500%,-200%);
    }
    80%{
        transform: translate(-600%,-150%);
    }
    90%{
        transform: translate(-620%,-50%);
    }
    100%{
       transform: translate(-650%,-10%);
    }
    
}
 

Trending Posts

Is Web Development a Good Career?

How Long Does It Take to Learn Programming?

Easy Light Bulb Project: HTML, CSS, and JavaScript

How to Become a Web Designer: A Complete Guide

60hz vs 90hz vs 120hz | Which One is Best? | What is Refresh Rate?

How To Create a Fake Facebook Login Clone Using Only HTML and CSS?

Brief History Of Computer

How To Create A Magic 8 Ball Using HTML, CSS, and JavaScript?

Is HTML a Programming Language?

Shield Your Small Business: Must-Have Cybersecurity Strategies