Skip to content
Advertisements

CSS Rotation Animation


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>
            <span></span>
            <span></span>
            <span></span>
            <span></span>
            <span></span>
        </div>
    </div>

</body>
</html>

CSS CODE:

body{
    margin: 0;
    padding: 0;
    background-color: #1a1a1a
}
.box{
    position: absolute;
    top: calc(50% - 100px);
    left: calc(50% - 135px);
    height: 200px;
    transform-style: preserve-3d;
    transform: perspective(1000px) rotateY(45deg);
}
.box div{
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    display: flex;
    transform-style: preserve-3d;
}
.box div span{
    display: block;
    position: relative;
    width: 50px;
    height: 100px;
    background: linear-gradient(#ffcc00 , #000000, #ffcc00);
    animation: ani 2.8s linear infinite
}
.box div span:before{
    content: "";
    position: absolute;
    display: block;
    width: 100%;
    height: 100%;
    background-color: #990000;
    transform-style: preserve-3d;
    transform: translateX(-25px) scaleY(.5);
}
.box div span:nth-child(1){
    animation-delay: 0s;
}
.box div span:nth-child(2){
    animation-delay: 0.2s;
}
.box div span:nth-child(3){
    animation-delay: 0.4s;
}
.box div span:nth-child(4){
    animation-delay: 0.6s;
}
.box div span:nth-child(5){
    animation-delay: 0.8s;
}
.box div span:nth-child(6){
    animation-delay: 1s;
}
.box div span:nth-child(7){
    animation-delay: 1.2s;
}
.box div span:nth-child(8){
    animation-delay: 1.4s;
}
.box div span:nth-child(9){
    animation-delay: 1.6s;
}
@keyframes ani{
    0%{
        transform: rotateX(0deg);
    }
    100%{
        transform: rotateX(360deg);
    }
}
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: