Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Selected Reading
Light Speed In Animation Effect with CSS
The CSS light speed in animation effect creates a dramatic entrance where an element appears to speed in from the right side of the screen with a skewing motion that simulates high-speed movement.
Syntax
@keyframes lightSpeedIn {
0% {
transform: translateX(100%) skewX(-30deg);
opacity: 0;
}
100% {
transform: translateX(0%) skewX(0deg);
opacity: 1;
}
}
.element {
animation: lightSpeedIn duration timing-function;
}
How It Works
The light speed effect combines three key transformations −
- translateX() − Moves the element horizontally from right to left
- skewX() − Creates a slanted appearance simulating motion blur
- opacity − Controls visibility for a smooth fade-in effect
Example
The following example demonstrates the light speed in animation effect −
<!DOCTYPE html>
<html>
<head>
<style>
.animated-box {
width: 200px;
height: 100px;
background: linear-gradient(45deg, #ff6b6b, #4ecdc4);
margin: 50px auto;
border-radius: 10px;
display: flex;
align-items: center;
justify-content: center;
color: white;
font-weight: bold;
animation: lightSpeedIn 0.8s ease-out;
}
@keyframes lightSpeedIn {
0% {
transform: translateX(100%) skewX(-30deg);
opacity: 0;
}
60% {
transform: translateX(-20%) skewX(30deg);
opacity: 1;
}
80% {
transform: translateX(0%) skewX(-15deg);
opacity: 1;
}
100% {
transform: translateX(0%) skewX(0deg);
opacity: 1;
}
}
.trigger-btn {
display: block;
margin: 20px auto;
padding: 10px 20px;
background-color: #333;
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
}
</style>
</head>
<body>
<div class="animated-box">Light Speed!</div>
<button class="trigger-btn" onclick="location.reload()">Replay Animation</button>
</body>
</html>
A colorful box with gradient background appears to speed in from the right side with a skewing motion, creating a light speed effect. The animation takes 0.8 seconds with smooth easing.
Key Animation Properties
| Property | Purpose | Value Range |
|---|---|---|
translateX() |
Horizontal movement | 100% to 0% |
skewX() |
Creates speed distortion | -30deg to 0deg |
opacity |
Fade-in effect | 0 to 1 |
timing-function |
Easing curve | ease-out recommended |
Conclusion
The light speed in animation creates an impressive entrance effect by combining translation, skewing, and opacity changes. The skew transformation is crucial for simulating the visual distortion of high-speed movement, making elements appear to streak into position.
Advertisements
