CSS Keyframe Animations
Create smooth keyframe animations with transform and opacity for performing transitions without layout thrashing.
Code
@keyframes fadeIn {
from { opacity: 0; transform: translateY(20px); }
to { opacity: 1; transform: translateY(0); }
}
.animate-fade {
animation: fadeIn 0.3s ease-out forwards;
}
@keyframes pulse {
0%, 100% { transform: scale(1); }
50% { transform: scale(1.05); }
}CSS Keyframe Animations
Create smooth keyframe animations with transform and opacity for performing transitions without layout thrashing.
Code
@keyframes fadeIn {
from { opacity: 0; transform: translateY(20px); }
to { opacity: 1; transform: translateY(0); }
}
.animate-fade {
animation: fadeIn 0.3s ease-out forwards;
}
@keyframes pulse {
0%, 100% { transform: scale(1); }
50% { transform: scale(1.05); }
}
Explanation
Two keyframes drive the compositor: fadeIn translates and fades an element in over 0.3s, while pulse scales it between 1 and 1.05 on a loop. Expected behavior: the animated element holds its final state because fadeIn uses forwards. Limitation: only transform and opacity stay cheap to animate; animating layout properties such as width or top forces reflow.
Interactive Tools for This Topic
Cubic Bezier PreviewPreview a CSS cubic-bezier() easing curve, validate the control points, and sample the progress mapping from input to output value.Aspect Ratio CalculatorSimplify a width-to-height ratio, show its decimal value, and derive a matching height for a new width.Border Radius PreviewPreview four-corner border-radius values on a live box and copy the generated shorthand border-radius CSS declaration.Box Shadow GeneratorBuild CSS box-shadow values with offset, blur, spread, color, opacity, and inset controls, with a live preview of the result.
Report a problem with this exampleOpens a pre-filled issue on GitHub.