Carbon Atom Animation

Developer
Size
5,507 Kb
Views
101,200

How do I make an carbon atom animation?

Almost pure css animation of a carbon atom, written in SCSS including mixins with prefixes!. What is a carbon atom animation? How do you make a carbon atom animation? This script and codes were developed by Mario Duarte on 04 August 2022, Thursday.

Carbon Atom Animation Previews

Carbon Atom Animation - Script Codes HTML Codes

<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Carbon Atom Animation</title> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css"> <link rel='stylesheet prefetch' href='https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css'> <link rel="stylesheet" href="css/style.css">
</head>
<body>	<div class="container">	<div class="atom animated">	<div class="protons-neutrons">	<span class="proton proton-1"></span>	<span class="proton proton-2"></span>	<span class="proton proton-3"></span>	<span class="proton proton-4"></span>	<span class="proton proton-5"></span>	<span class="proton proton-6"></span>	<span class="neutron neutron-1"></span>	<span class="neutron neutron-2"></span>	<span class="neutron neutron-3"></span>	<span class="neutron neutron-4"></span>	<span class="neutron neutron-5"></span>	<span class="neutron neutron-6"></span>	</div>	<div class="electrons electrons-1">	<span class="electron electron-1"></span>	<span class="electron electron-2"></span>	</div>	<div class="electrons electrons-2">	<span class="electron electron-1"></span>	<span class="electron electron-2"></span>	</div>	<div class="electrons electrons-3">	<span class="electron electron-1"></span>	<span class="electron electron-2"></span>	</div>	</div>	<div class="controls">	<span class='controls-toggle js-controls-toggle'><i class="fa fa-cog" aria-hidden="true"></i></span>	<div class="controls-content">	<h3>The anatomy of a Carbon Atom</h3>	<p><span class='control-neutron'></span> 6 Neutrons <smal>(neutral chage)</smal></p>	<p><span class='control-proton'></span> 6 Protons <smal>(positive charge)</smal></p>	<p><span class="control-electron"></span> 6 Electrons <smal>(negative charge)</smal></p>	<p><a href="#" class="btn js-toggle-movement">Stop animation</a></p>	</div>	</div>	</div> <script src='https://code.jquery.com/jquery-2.2.4.min.js'></script> <script src="js/index.js"></script>
</body>
</html>

Carbon Atom Animation - Script Codes CSS Codes

@-webkit-keyframes rotate { 0% { transform: rotate(0deg); -webkit-transform: rotate(0deg); -moz-transform: rotate(0deg); -ms-trasform: rotate(0deg); } 100% { transform: rotate(360deg); -webkit-transform: rotate(360deg); -moz-transform: rotate(360deg); -ms-trasform: rotate(360deg); }
}
@keyframes rotate { 0% { transform: rotate(0deg); -webkit-transform: rotate(0deg); -moz-transform: rotate(0deg); -ms-trasform: rotate(0deg); } 100% { transform: rotate(360deg); -webkit-transform: rotate(360deg); -moz-transform: rotate(360deg); -ms-trasform: rotate(360deg); }
}
@-webkit-keyframes moveAtom { 00% { top: 24%; left: 78%; } 10% { top: 32%; left: 92%; } 20% { top: 97%; left: 64%; } 30% { top: 84%; left: 52%; } 40% { top: 54%; left: 26%; } 50% { top: 10%; left: 98%; } 60% { top: 56%; left: 25%; } 70% { top: 52%; left: 28%; } 80% { top: 1%; left: 88%; } 90% { top: 99%; left: 89%; } 100% { top: 47%; left: 22%; }
}
@keyframes moveAtom { 00% { top: 24%; left: 78%; } 10% { top: 32%; left: 92%; } 20% { top: 97%; left: 64%; } 30% { top: 84%; left: 52%; } 40% { top: 54%; left: 26%; } 50% { top: 10%; left: 98%; } 60% { top: 56%; left: 25%; } 70% { top: 52%; left: 28%; } 80% { top: 1%; left: 88%; } 90% { top: 99%; left: 89%; } 100% { top: 47%; left: 22%; }
}
@-webkit-keyframes rotateNuclei { 0% { transform: rotate(0deg); -webkit-transform: rotate(0deg); -moz-transform: rotate(0deg); -ms-trasform: rotate(0deg); } 100% { transform: rotate(360deg); -webkit-transform: rotate(360deg); -moz-transform: rotate(360deg); -ms-trasform: rotate(360deg); }
}
@keyframes rotateNuclei { 0% { transform: rotate(0deg); -webkit-transform: rotate(0deg); -moz-transform: rotate(0deg); -ms-trasform: rotate(0deg); } 100% { transform: rotate(360deg); -webkit-transform: rotate(360deg); -moz-transform: rotate(360deg); -ms-trasform: rotate(360deg); }
}
@-webkit-keyframes electronX1 { 0% { left: 0; } 50% { left: 100%; } 100% { left: 0; }
}
@keyframes electronX1 { 0% { left: 0; } 50% { left: 100%; } 100% { left: 0; }
}
@-webkit-keyframes electronY1 { 0% { bottom: 0; } 50% { bottom: 200px; } 100% { bottom: 0; }
}
@keyframes electronY1 { 0% { bottom: 0; } 50% { bottom: 200px; } 100% { bottom: 0; }
}
@-webkit-keyframes electronX2 { 0% { right: 0; } 50% { right: 100%; } 100% { right: 0; }
}
@keyframes electronX2 { 0% { right: 0; } 50% { right: 100%; } 100% { right: 0; }
}
@-webkit-keyframes electronY2 { 0% { bottom: 0; } 50% { bottom: 200px; } 100% { bottom: 0; }
}
@keyframes electronY2 { 0% { bottom: 0; } 50% { bottom: 200px; } 100% { bottom: 0; }
}
body { margin: 0; padding: 0; font-family: 'helvetica', sans-serif; height: 100%; background-color: #eeeeee; transform: translate3d(0, 0, 0); -webkit-transform: translate3d(0, 0, 0); -moz-transform: translate3d(0, 0, 0); -ms-trasform: translate3d(0, 0, 0);
}
.container { width: 100vw; height: 100vh; position: relative; background-color: #dddddd; overflow: hidden;
}
.container .atom { width: 200px; height: 200px; position: absolute; top: calc(50% - 100px); left: calc(50% - 100px); transition: all 0.8s ease-in-out; -webkit-transition: all 0.8s ease-in-out; -moz-transition: all 0.8s ease-in-out; -ms-transition: all 0.8s ease-in-out;
}
.container .atom.animated { -webkit-animation: moveAtom 240s ease-in-out 0s infinite forwards; animation: moveAtom 240s ease-in-out 0s infinite forwards;
}
.container .atom .protons-neutrons { width: 100px; height: 100px; position: absolute; top: calc(50% - 50px); left: calc(50% - 50px); -webkit-animation: rotateNuclei 2s linear 0s infinite forwards; animation: rotateNuclei 2s linear 0s infinite forwards;
}
.container .atom .protons-neutrons .proton { transition: all 0.2s ease-in-out; -webkit-transition: all 0.2s ease-in-out; -moz-transition: all 0.2s ease-in-out; -ms-transition: all 0.2s ease-in-out; width: 15px; height: 15px; display: inline-block; color: #ffffff; background-color: #16a085; border-radius: 100%; -webkit-border-radius: 100%; -moz-border-radius: 100%; -ms-border-radius: 100%; position: absolute; z-index: 5; box-shadow: inset 5px 5px 5px 0px rgba(255, 255, 255, 0.3);
}
.container .atom .protons-neutrons .proton.proton-1 { top: 42.5px; left: 42.5px;
}
.container .atom .protons-neutrons .proton.proton-2 { top: 30px; left: 42.5px;
}
.container .atom .protons-neutrons .proton.proton-3 { top: 55px; left: 42.5px;
}
.container .atom .protons-neutrons .proton.proton-4 { top: 42.5px; left: 30px;
}
.container .atom .protons-neutrons .proton.proton-5 { top: 42.5px; left: 55px;
}
.container .atom .protons-neutrons .proton.proton-6 { top: 30px; left: 20px;
}
.container .atom .protons-neutrons .neutron { transition: all 0.2s ease-in-out; -webkit-transition: all 0.2s ease-in-out; -moz-transition: all 0.2s ease-in-out; -ms-transition: all 0.2s ease-in-out; width: 15px; height: 15px; display: inline-block; color: #ffffff; background-color: #c0392b; border-radius: 100%; -webkit-border-radius: 100%; -moz-border-radius: 100%; -ms-border-radius: 100%; position: absolute; z-index: 4; box-shadow: inset 5px 5px 5px 0px rgba(255, 255, 255, 0.3);
}
.container .atom .protons-neutrons .neutron.neutron-1 { top: 30px; left: 30px;
}
.container .atom .protons-neutrons .neutron.neutron-2 { top: 30px; left: 55px;
}
.container .atom .protons-neutrons .neutron.neutron-3 { top: 55px; left: 30px;
}
.container .atom .protons-neutrons .neutron.neutron-4 { top: 55px; left: 55px;
}
.container .atom .protons-neutrons .neutron.neutron-5 { top: 42.5px; left: 65px;
}
.container .atom .protons-neutrons .neutron.neutron-6 { top: 42.5px; left: 20px;
}
.container .atom .electrons { width: 100%; height: 100%; position: absolute; top: 0; left: 0; z-index: 6;
}
.container .atom .electrons.electrons-1 { transform: rotate(0deg); -webkit-transform: rotate(0deg); -moz-transform: rotate(0deg); -ms-trasform: rotate(0deg);
}
.container .atom .electrons.electrons-1 .electron-1 { bottom: 0; left: 0; -webkit-animation: electronX1 0.7s linear 0s infinite forwards; animation: electronX1 0.7s linear 0s infinite forwards;
}
.container .atom .electrons.electrons-1 .electron-1:after { -webkit-animation: electronY1 0.7s cubic-bezier(0, 0.5, 0.5, 1) 0s infinite forwards; animation: electronY1 0.7s cubic-bezier(0, 0.5, 0.5, 1) 0s infinite forwards;
}
.container .atom .electrons.electrons-1 .electron-2 { bottom: 0; right: 0; -webkit-animation: electronX2 0.7s linear 0s infinite forwards; animation: electronX2 0.7s linear 0s infinite forwards;
}
.container .atom .electrons.electrons-1 .electron-2:after { -webkit-animation: electronY2 0.7s cubic-bezier(0, 0.5, 0.5, 1) 0s infinite forwards; animation: electronY2 0.7s cubic-bezier(0, 0.5, 0.5, 1) 0s infinite forwards;
}
.container .atom .electrons.electrons-2 { transform: rotate(22.5deg); -webkit-transform: rotate(22.5deg); -moz-transform: rotate(22.5deg); -ms-trasform: rotate(22.5deg);
}
.container .atom .electrons.electrons-2 .electron-1 { bottom: 0; left: 0; -webkit-animation: electronX1 0.2s linear 0s infinite forwards; animation: electronX1 0.2s linear 0s infinite forwards;
}
.container .atom .electrons.electrons-2 .electron-1:after { -webkit-animation: electronY1 0.2s cubic-bezier(0, 0.5, 0.5, 1) 0s infinite forwards; animation: electronY1 0.2s cubic-bezier(0, 0.5, 0.5, 1) 0s infinite forwards;
}
.container .atom .electrons.electrons-2 .electron-2 { bottom: 0; right: 0; -webkit-animation: electronX2 0.2s linear 0s infinite forwards; animation: electronX2 0.2s linear 0s infinite forwards;
}
.container .atom .electrons.electrons-2 .electron-2:after { -webkit-animation: electronY2 0.2s cubic-bezier(0, 0.5, 0.5, 1) 0s infinite forwards; animation: electronY2 0.2s cubic-bezier(0, 0.5, 0.5, 1) 0s infinite forwards;
}
.container .atom .electrons.electrons-3 { transform: rotate(45deg); -webkit-transform: rotate(45deg); -moz-transform: rotate(45deg); -ms-trasform: rotate(45deg);
}
.container .atom .electrons.electrons-3 .electron-1 { bottom: 0; left: 0; -webkit-animation: electronX1 0.5s linear 0s infinite forwards; animation: electronX1 0.5s linear 0s infinite forwards;
}
.container .atom .electrons.electrons-3 .electron-1:after { -webkit-animation: electronY1 0.5s cubic-bezier(0, 0.5, 0.5, 1) 0s infinite forwards; animation: electronY1 0.5s cubic-bezier(0, 0.5, 0.5, 1) 0s infinite forwards;
}
.container .atom .electrons.electrons-3 .electron-2 { bottom: 0; right: 0; -webkit-animation: electronX2 0.5s linear 0s infinite forwards; animation: electronX2 0.5s linear 0s infinite forwards;
}
.container .atom .electrons.electrons-3 .electron-2:after { -webkit-animation: electronY2 0.5s cubic-bezier(0, 0.5, 0.5, 1) 0s infinite forwards; animation: electronY2 0.5s cubic-bezier(0, 0.5, 0.5, 1) 0s infinite forwards;
}
.container .atom .electrons .electron { width: 15px; height: 15px; display: inline-block; color: #ffffff; position: absolute;
}
.container .atom .electrons .electron:after { content: ''; background-color: #3498db; border-radius: 100%; -webkit-border-radius: 100%; -moz-border-radius: 100%; -ms-border-radius: 100%; width: 15px; height: 15px; display: inline-block; color: #ffffff; position: absolute; bottom: 0; left: 0; box-shadow: inset 5px 5px 5px 0px rgba(255, 255, 255, 0.3);
}
.container .controls { position: absolute; top: 20px; left: 20px; width: 200px; z-index: 99;
}
.container .controls span.controls-toggle { color: #eee; padding: 8px 10px; border-radius: 100%; background-color: #3498db; display: inline-block;
}
.container .controls span.controls-toggle i { font-size: 28px;
}
.container .controls .controls-content { width: 100%; position: absolute; top: 40px; left: 0; background-color: #eee; padding: 10px 20px; pointer-events: none; opacity: 0; transition: all 0.8s ease-in-out; -webkit-transition: all 0.8s ease-in-out; -moz-transition: all 0.8s ease-in-out; -ms-transition: all 0.8s ease-in-out;
}
.container .controls .controls-content.open { top: 60px; pointer-events: auto; opacity: 1;
}
.container .controls .controls-content h3 { font-weight: lighter; font-size: 18px; color: #3498db;
}
.container .controls .controls-content p { font-size: 14px; color: #999999;
}
.container .controls .controls-content p smal { font-size: 12px; color: #555555;
}
.container .controls .controls-content .control-neutron { width: 12px; height: 12px; display: inline-block; color: #ffffff; background-color: #c0392b; border-radius: 100%; -webkit-border-radius: 100%; -moz-border-radius: 100%; -ms-border-radius: 100%; box-shadow: inset 5px 5px 5px 0px rgba(255, 255, 255, 0.3); -webkit-animation: rotate 0.5s linear 0s infinite forwards; animation: rotate 0.5s linear 0s infinite forwards;
}
.container .controls .controls-content .control-proton { width: 12px; height: 12px; display: inline-block; color: #ffffff; background-color: #16a085; border-radius: 100%; -webkit-border-radius: 100%; -moz-border-radius: 100%; -ms-border-radius: 100%; box-shadow: inset 5px 5px 5px 0px rgba(255, 255, 255, 0.3); -webkit-animation: rotate 0.5s linear 0s infinite forwards; animation: rotate 0.5s linear 0s infinite forwards;
}
.container .controls .controls-content .control-electron { width: 12px; height: 12px; display: inline-block; color: #ffffff; background-color: #3498db; border-radius: 100%; -webkit-border-radius: 100%; -moz-border-radius: 100%; -ms-border-radius: 100%; box-shadow: inset 5px 5px 5px 0px rgba(255, 255, 255, 0.3); -webkit-animation: rotate 0.5s linear 0s infinite forwards; animation: rotate 0.5s linear 0s infinite forwards;
}
.container .controls .btn { margin: 10px 0 0 0; padding: 5px 15px; color: #ffffff; background: #16a085; border-radius: 5px; border: 1px solid #107360; font-size: 12px; text-decoration: none; display: inline-block;
}
.container .controls .btn:hover { background-color: #107360;
}
.container .controls:hover span.controls-toggle { cursor: pointer;
}
.container .controls:hover span.controls-toggle i { -webkit-animation: rotate 2s linear 0s infinite forwards; animation: rotate 2s linear 0s infinite forwards;
}

Carbon Atom Animation - Script Codes JS Codes

// Jquery only for the controls, animation is pure css
$(document).ready(function(){	$('body').on('click', '.js-toggle-movement', function(e){	$('.atom').toggleClass('animated');	$(this).text(function(e, v){	return v === "Animate movement" ? "Stop animation" : "Animate movement"	});	});	$('body').on('click', '.js-controls-toggle', function(e){	e.preventDefault();	$('.controls-content').toggleClass('open');	});
});
Carbon Atom Animation - Script Codes
Carbon Atom Animation - Script Codes
Home Page Home
Developer Mario Duarte
Username MarioDesigns
Uploaded August 04, 2022
Rating 3
Size 5,507 Kb
Views 101,200
Do you need developer help for Carbon Atom Animation?

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!

Mario Duarte (MarioDesigns) Script Codes
Create amazing web content with AI!

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!