Skip to content

Instantly share code, notes, and snippets.

@tilomitra
Last active March 27, 2023 13:55
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tilomitra/36d0fc8ddbb03b88e0d9 to your computer and use it in GitHub Desktop.
Save tilomitra/36d0fc8ddbb03b88e0d9 to your computer and use it in GitHub Desktop.
Common CSS Infinite Animations (pulsate, opacityPulse, alertPulse, rotating).
/* Make the element pulse (grow large and small slowly) */
/* Usage
.myElement {
animation: pulsate 1s ease-out;
animation-iteration-count: infinite;
opacity: 1;
}
*/
@-webkit-keyframes pulsate {
0% {-webkit-transform: scale(0.1, 0.1); opacity: 0.0;}
50% {opacity: 1.0;}
100% {-webkit-transform: scale(1.2, 1.2); opacity: 0.0;}
}
/* Make the element's opacity pulse*/
/* Usage
.myElement {
animation: opacityPulse 1s ease-out;
animation-iteration-count: infinite;
opacity: 0;
}
*/
@-webkit-keyframes opacityPulse {
0% {opacity: 0.0;}
50% {opacity: 1.0;}
100% {opacity: 0.0;}
}
/* Make the element's background pulse. I call this alertPulse because it is red. You can call it something more generic. */
/* Usage
.myElement {
animation: alertPulse 1s ease-out;
animation-iteration-count: infinite;
opacity: 1;
}
*/
@-webkit-keyframes alertPulse {
0% {background-color: #9A2727; opacity: 1;}
50% {opacity: red; opacity: 0.75; }
100% {opacity: #9A2727; opacity: 1;}
}
/* Make the element rotate infinitely. */
/*
Usage
.myElement {
animation: rotating 3s linear infinite;
}
*/
@keyframes rotating {
from {
-ms-transform: rotate(0deg);
-moz-transform: rotate(0deg);
-webkit-transform: rotate(0deg);
-o-transform: rotate(0deg);
transform: rotate(0deg);
}
to {
-ms-transform: rotate(360deg);
-moz-transform: rotate(360deg);
-webkit-transform: rotate(360deg);
-o-transform: rotate(360deg);
transform: rotate(360deg);
}
}
Copy link

ghost commented Jan 5, 2016

This looks wrong - did you mean background-color?

50% {opacity: red; opacity: 0.75; }
100% {opacity: #9A2727; opacity: 1;}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment