Using Transitions and Animations for Dynamic Effects
User experience is enhanced by dynamic effects and interaction provided by transitions and animations.
Transition: When a state of an element changes, its attributes gradually alter over time.
An animation is a more intricate form of style change based on pre-established keyframes than a transition.
Code
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Transitions and Animations Example</title> <style> .transition { width: 100px; height: 100px; background-color: #4CAF50; transition: width 2s; } .transition:hover { width: 300px; } @keyframes example { from {background-color: red;} to {background-color: yellow;} } .animation { width: 100px; height: 100px; background-color: red; animation-name: example; animation-duration: 4s; } </style> </head> <body> <div class="transition">Hover over me!</div> <div class="animation"></div> </body> </html> |
Using Transitions and Animations for Dynamic Effects
User experience is enhanced by dynamic effects and interaction provided by transitions and animations.
Transition: When a state of an element changes, its attributes gradually alter over time.
An animation is a more intricate form of style change based on pre-established keyframes than a transition.
Code
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Transitions and Animations Example</title> <style> .transition { width: 100px; height: 100px; background-color: #4CAF50; transition: width 2s; } .transition:hover { width: 300px; } @keyframes example { from {background-color: red;} to {background-color: yellow;} } .animation { width: 100px; height: 100px; background-color: red; animation-name: example; animation-duration: 4s; } </style> </head> <body> <div class="transition">Hover over me!</div> <div class="animation"></div> </body> </html> |
Copyrights © 2024 letsupdateskills All rights reserved