CSS - Fade Out Right Effect



Description

The image come or cause to come gradually into or out of view, or to merge into another shot.

Syntax

 @keyframes fadeOutRight { 0% { opacity: 1; transform: translateX(0); } 100% { opacity: 0; transform: translateX(20px); } } 

Parameters

  • Transform − Transform applies to 2d and 3d transformation to an element.

  • Opacity − Opacity applies to an element to make translucence.

Example

 <!DOCTYPE html> <html lang="en"> <head> <style> .forAnimated { background-image: url(/html/images/test.png); background-repeat: no-repeat; background-position: left top; padding-top: 95px; margin-bottom: 60px; -webkit-animation-duration: 2s; animation-duration: 2s; -webkit-animation-fill-mode: both; animation-fill-mode: both; } @-webkit-keyframes fadeOutRight { 0% { opacity: 1; -webkit-transform: translateX(0); } 100% { opacity: 0; -webkit-transform: translateX(80px); } } @keyframes fadeOutRight { 0% { opacity: 1; transform: translateX(0); } 100% { opacity: 0; transform: translateX(80px); } } .fadeOutRight { -webkit-animation-name: fadeOutRight; animation-name: fadeOutRight; } </style> </head> <body> <div id="forAnimates" class="forAnimated"></div> <button onclick="forFunc()">Click</button> <script> function forFunc() { document.getElementById("forAnimates").classList.add('fadeOutRight'); } </script> </body> </html> 

Output

It will produce the following result:

Fade Out Right Effect
css_animation.htm
Advertisements