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 Up Animation Effect with CSS
The CSS fade out up animation effect creates a smooth transition where an element gradually fades out while moving upward. This effect is commonly used for removing elements from view with a subtle upward motion.
Syntax
@keyframes fadeOutUp {
from {
opacity: 1;
transform: translateY(0);
}
to {
opacity: 0;
transform: translateY(-distance);
}
}
.element {
animation: fadeOutUp duration timing-function;
}
Example
The following example demonstrates how to implement a fade out up animation effect on a div element −
<!DOCTYPE html>
<html>
<head>
<style>
.animated-box {
width: 200px;
height: 100px;
background-color: #3498db;
color: white;
display: flex;
align-items: center;
justify-content: center;
margin: 50px auto;
border-radius: 8px;
animation-duration: 2s;
animation-fill-mode: both;
}
@keyframes fadeOutUp {
0% {
opacity: 1;
transform: translateY(0);
}
100% {
opacity: 0;
transform: translateY(-30px);
}
}
.fadeOutUp {
animation-name: fadeOutUp;
}
</style>
</head>
<body>
<div class="animated-box fadeOutUp">Fading Out Up</div>
<button onclick="location.reload()">Reload Animation</button>
</body>
</html>
A blue box with white text "Fading Out Up" appears and then smoothly fades out while moving upward by 30 pixels over 2 seconds. A reload button allows you to restart the animation.
Key Animation Properties
| Property | Description | Value in Example |
|---|---|---|
opacity |
Controls the transparency of the element | 1 to 0 (fully visible to invisible) |
transform: translateY() |
Moves the element vertically | 0 to -30px (upward movement) |
animation-duration |
How long the animation takes | 2s |
animation-fill-mode |
Retains the final animation state | both |
Conclusion
The fade out up animation combines opacity and transform properties to create a smooth exit effect. By adjusting the translateY value and duration, you can customize the speed and distance of the upward movement to match your design needs.
Advertisements
