CSS animations allow us to animate the transformations of elements
Here's the rotating shrug code.
The @keyframes
rules specify how long the animation should take and what course the animation should take, such as "be rotated at 180deg 50% along the animation" in case of animated asciishrug.
By using the infinite
parameter to the animation we ensure it is looping forever and ever (because why not).
The direction of a single animation can be one of normal, reverse, alternate or alternate-reverse
.
#divanimate-shrug {
text-align: center;
border-radius: 7px;
padding: 5px 0;
min-height: 100px;
margin: 1em 3em;
animation: rotate-shrug 4s infinite;
-webkit-animation: rotate-shrug 4s infinite;
animation-direction: alternate;
background: transparent;
opacity: 0.95;
}
#divanimate-shrug h1 {
font-family: 'Fira Code Retina';
text-rendering: optimizeLegibility;
font-feature-settings: "ss07", "zero";
}
@keyframes rotate-shrug {
0% {
transform: rotateY(0deg);
}
50% {
transform: rotateY(180deg);
}
100% {
transform: rotateY(360deg);
}
}
Here's a div infinitely rotating along its x-axis.
#divanimate-x {
text-align: center;
border-radius: 7px;
padding: 5px 0;
min-height: 100px;
margin: 0 3em;
animation: rotate-x 4s infinite;
-webkit-animation: rotate-x 4s infinite;
-webkit-transform: rotateX(60deg);
transform: rotateX(60deg);
animation-direction: alternate;
background: rgb(2,0,36);
background: radial-gradient(
circle,
rgba(2,0,36,1) 0%,
rgba(9,9,121,1) 52%,
rgba(0,212,255,1) 100%
);
opacity: 0.95;
}
#divanimate-x h1 {
font-family: 'Fira Code Retina';
text-rendering: optimizeLegibility;
font-feature-settings: "ss07", "zero";
}
@keyframes rotate-x {
0% {
transform: rotateX(-60deg);
}
100% {
transform: rotateX(60deg);
}
}
Here's a div infinitely rotating along its y-axis.
#divanimate-y {
text-align: center;
border-radius: 7px;
padding: 5px 0;
min-height: 100px;
margin: 1em 3em;
animation: rotate-y 4s infinite;
-webkit-animation: rotate-y 4s infinite;
animation-direction: alternate;
background: rgb(2,0,36);
background: radial-gradient(
circle,
rgba(2,0,36,1) 0%,
rgba(9,9,121,1) 42%,
rgba(0,212,255,1) 100%
);
opacity: 0.95;
}
#divanimate-y h1 {
font-family: 'Fira Code Retina';
text-rendering: optimizeLegibility;
font-feature-settings: "ss07", "zero";
}
@keyframes rotate-y {
0% {
transform: rotateY(-50deg);
}
100% {
transform: rotateY(50deg);
}
}
Here's a div infinitely rotating along its z-axis.
#divanimate-z {
text-align: center;
border-radius: 7px;
padding: 5px 0;
min-height: 100px;
margin: 0 3em;
animation: rotate-z 3s infinite;
-webkit-animation: rotate-z 3s infinite;
animation-direction: alternate;
background: rgb(2,0,36);
background: radial-gradient(
circle,
rgba(2,0,36,1) 0%,
rgba(9,9,121,1) 52%,
rgba(0,212,255,1) 100%
);
opacity: 0.95;
}
#divanimate-z h1 {
font-family: 'Fira Code Retina';
text-rendering: optimizeLegibility;
font-feature-settings: "ss07", "zero";
}
@keyframes rotate-z {
0% {
transform: rotateZ(-20deg);
}
50% {
transform: rotateZ(0deg);
}
100% {
transform: rotateZ(20deg);
}
}