Simple CSS3 animation with JavaScript
How do I make an simple css3 animation with javascript?
Enabling CSS3 animation by adding a class to an element. . What is a simple css3 animation with javascript? How do you make a simple css3 animation with javascript? This script and codes were developed by Mattia A Fritz on 26 August 2022, Friday.
Simple CSS3 animation with JavaScript - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Simple CSS3 animation with JavaScript</title> <link rel="stylesheet" href="css/style.css">
</head>
<body> <div id="myDiv">Moving color box</div>
<button id="animationBtn">Animate</button>
<button id="resetBtn">Reset</button> <script src="js/index.js"></script>
</body>
</html>
Simple CSS3 animation with JavaScript - Script Codes CSS Codes
/* The animation code */
@keyframes example { from { background-color: red; maring-left: 0px; color: #FFF; } to { background-color: yellow; margin-left: 600px; color: #000; }
}
div { width: 300px; height: 200px; background-color: red; margin-bottom: 20px; line-height: 200px; text-align: center; font-size: 2em; color: #FFF; border: 1px solid #000;
}
/* The element to apply the animation to */
div.animation { animation-name: example; animation-duration: 5s; animation-fill-mode: forwards;
}
Simple CSS3 animation with JavaScript - Script Codes JS Codes
//Identifier le div à animer dans le DOM
var myDIv = document.getElementById("myDv");
//Animation suite au click sur le bouton
document.getElementById("animationBtn").onclick = function() { //Ajouter la class avec l'animation CSS3 au div myDiv.classList.add("animation");
}
//Reset
document.getElementById("resetBtn").onclick = function () { //Enlever la class avec l'animation CSS3 au div myDiv.classList.remove("animation");
}
Developer | Mattia A Fritz |
Username | mafritz |
Uploaded | August 26, 2022 |
Rating | 3 |
Size | 2,029 Kb |
Views | 60,720 |
Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!
Name | Size |
P5.js example redefine draw function | 1,942 Kb |
Simple manipulation du DOM avec JavaScript | 1,887 Kb |
Simple animation SVG avec JavaScript | 2,206 Kb |
CSS animation | 1,663 Kb |
Use CSS to style SVG elements | 1,622 Kb |
P5.js example with button | 1,853 Kb |
Utiliser dynamiquement des classes avec JavaScript | 2,005 Kb |
Client Side JavaScript basic example | 1,814 Kb |
JavaScript and time | 1,657 Kb |
Different size of columns according to screen size | 1,637 Kb |
Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!
Name | Username | Size |
Project Euler Problem 17 | Bfillmer | 2,739 Kb |
Sass Radar | Jlong | 6,887 Kb |
Flat iOS 7 Safari Icon | Rss | 3,332 Kb |
A Pen by Eka Risyana | Risyana | 3,705 Kb |
Funny menu | AxeLVaisper | 4,671 Kb |
Custom Checkbox and radio inputs SCSS | Rgfx | 3,367 Kb |
Border-radius animation | Yukulele | 2,480 Kb |
The CodePen Logo | Kindofone | 4,259 Kb |
Weather App | OmranAbazid | 2,596 Kb |
Mobile Sub Menu Concept | Berdejitendra | 2,790 Kb |
Surf anonymously, prevent hackers from acquiring your IP address, send anonymous email, and encrypt your Internet connection. High speed, ultra secure, and easy to use. Instant setup. Hide Your IP Now!