Skip to content

CSS Animation – Endless Loop


HTML CODE:

<!DOCTYPE html>
<html>
<head>
    <title>page</title>
    <link rel="stylesheet" type="text/css" href="1.page.css">

</head>
<body>

    <div class="box">
        <div>
            <span></span>
            <span></span>
            <span></span>
            <span></span>
        </div>
    </div>
    
</body>
</html>

CSS CODE

body{
    margin:0;
    padding: 0;
    background-color: #fff;
}
.box{
    position: absolute;
    top: calc(50% - 300px);
    left: calc(50% - 200px);
    transform:perspective(1000px) rotateY(-45deg);
    width:400px;
    height: 600px;
    transform-style: preserve-3d;
}
.box:before{
    content: "";
    position: absolute;
    bottom: -100px;
    left: 0;
    width: 100%;
    height: 50px;
    background: #000;
    filter: blur(30px);
    opacity: 0.5;
    transform: rotateX(90deg);
}
.box div{
    position: absolute;
    top:0;
    left: 0;
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
    animation: ani 5s linear infinite;
}
.box div span{
    position: absolute;
    top: 0;
    left: 0;
    display: block;
    width: 100%;
    height: 100%;
    background: linear-gradient(0deg, #f1f1f1, #bbb, #f1f1f1);
    border-radius:100%;
    border:2px solid #fff;
}
.box div span:nth-child(1){
    transform: rotateX(0deg);
    background:url(https://i.pinimg.com/originals/a8/26/c6/a826c6d113402d93ad50be649e84ac31.jpg);
    background-size: cover;
}
.box div span:nth-child(2){
    transform: rotateX(45deg);
    background:url(https://i.pinimg.com/originals/a8/26/c6/a826c6d113402d93ad50be649e84ac31.jpg);
    background-size: cover 
}
.box div span:nth-child(3){
    transform: rotateX(-45deg);
    background:url(https://i.pinimg.com/originals/a8/26/c6/a826c6d113402d93ad50be649e84ac31.jpg);
    background-size: cover 
}
.box div span:nth-child(4){
    transform: rotateX(90deg);
    background:url(https://i.pinimg.com/originals/a8/26/c6/a826c6d113402d93ad50be649e84ac31.jpg);
    background-size: cover 
}
@keyframes ani{
    0%{
        transform: perspective(1000px) rotateX(0deg);
    }
    100%{
        transform: perspective(1000px) rotateX(360deg);
    }
}

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: