Skip to content
Advertisements

CSS Newton’s Cradle


HTML CODE:

<!DOCTYPE html>
<html>
<head>
    <title>page</title>
    <link rel="stylesheet" type="text/css" href="2.page.css">
    <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.4.1/css/all.css">
</head>
<body>

    <div class="loader">
        <span></span>
        <span></span>
        <span></span>
        <span></span>
        <span></span>
    </div>

</body>
</html>

CSS CODE:

body{
    padding: 0;
    margin: 0;
}
.loader{
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%,-50%);
    border-top: 4px solid #262626;
    border-bottom: 40px solid #262626;
    border-left: 1px solid #262626;
    border-right: 1px solid #262626;
    display: flex;
    padding: 0 40px 20px;
}
.loader span{
    position: relative;
    display: block;
    width: 2px;
    height: 100px;
    background-color: #262626;
    margin: 0 14px;
    transform-origin: top;
}
.loader span:before{
    content: "";
    position: absolute;
    bottom: -5px;
    left: -14px;
    width: 30px;
    height: 30px;
    background-color: #262626;
    border-radius: 50%;
}
.loader span:first-child{
    animation: ani1 1s linear infinite;
}
@keyframes ani1{
    0%{
        transform: rotate(0deg);
    }
    25%{
        transform: rotate(60deg);
    }
    50%{
        transform: rotate(0deg);
    }
    100%{
        transform: rotate(0deg);
    }
}
.loader span:last-child{
    animation: ani2 1s linear infinite;
    animation-delay: .5s;
}
@keyframes ani2{
    0%{
        transform: rotate(0deg);
    }
    25%{
        transform: rotate(-60deg);
    }
    50%{
        transform: rotate(0deg);
    }
    100%{
        transform: rotate(0deg);
    }
}
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: