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
Fade Out Left Animation Effect with CSS
The fade out left animation effect smoothly moves an element to the left while reducing its opacity to zero, creating a disappearing effect that slides leftward. This animation combines translation and opacity changes for a smooth exit transition.
Syntax
@keyframes fadeOutLeft {
0% {
opacity: 1;
transform: translateX(0);
}
100% {
opacity: 0;
transform: translateX(-20px);
}
}
.element {
animation-name: fadeOutLeft;
animation-duration: 1s;
}
Example: Fade Out Left Animation
The following example demonstrates the fade out left animation effect on a box element −
<!DOCTYPE html>
<html>
<head>
<style>
.box {
width: 150px;
height: 100px;
background-color: #3498db;
color: white;
display: flex;
align-items: center;
justify-content: center;
margin: 50px auto;
font-weight: bold;
border-radius: 8px;
animation: fadeOutLeft 2s ease-in-out;
animation-fill-mode: both;
}
@keyframes fadeOutLeft {
0% {
opacity: 1;
transform: translateX(0);
}
100% {
opacity: 0;
transform: translateX(-50px);
}
}
.reload-btn {
display: block;
margin: 20px auto;
padding: 10px 20px;
background-color: #2ecc71;
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
}
</style>
</head>
<body>
<div class="box">Fade Out Left</div>
<button class="reload-btn" onclick="location.reload()">Restart Animation</button>
</body>
</html>
A blue box with "Fade Out Left" text appears centered on the page, then gradually moves to the left while fading out over 2 seconds until it disappears completely. A green "Restart Animation" button allows you to replay the effect.
Animation Properties
| Property | Value | Description |
|---|---|---|
animation-duration |
2s | Controls how long the animation takes to complete |
animation-fill-mode |
both | Maintains the final animation state |
transform |
translateX(-50px) | Moves the element 50 pixels to the left |
opacity |
0 | Makes the element completely transparent |
Conclusion
The fade out left animation creates an elegant exit effect by combining leftward movement with opacity reduction. Adjust the translateX value to control the distance and animation-duration for timing.
Advertisements
