Hosting Solutions
mobile_logo Table of Contents
seal_frontseal_back

Holiday Christmas Lights Animation Tutorial CSS JavaScript

Learn to design, animate and render a set of holiday light bulbs using CSS and JavaScript.

Lesson Code <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <style> body { background:#000; } .bulb { width: 40px; height: 40px; display: inline-block; margin: 0px 10px; border-radius: 100% 4px; transform: rotate(-45deg); } .bulb:nth-child(odd) { background: #6CB6FF; opacity: 1; box-shadow: 1px 1px 15px #6CB6FF, -1px -1px 15px #6CB6FF; animation: bulb-pulse-1 0.8s linear 0s infinite alternate; } .bulb:nth-child(even) { background: #0C0; opacity: .3; box-shadow: none; animation: bulb-pulse-2 0.8s linear 0s infinite alternate; } @keyframes bulb-pulse-1 { from { box-shadow: 1px 1px 15px #6CB6FF, -1px -1px 15px #6CB6FF; opacity: 1; } to { box-shadow: none; opacity: .3; } } @keyframes bulb-pulse-2 { from { box-shadow: none; opacity: .3; } to { box-shadow: 1px 1px 15px #0C0, -1px -1px 15px #0C0; opacity: 1; } } </style> </head> <body> <div id="lights"></div> <script> for(var i=0; i < 10; i++){ var bulb = document.createElement("div"); bulb.className = "bulb"; // var rand = Math.floor(Math.random() * 180) + 1; // bulb.style.transform = "rotate("+rand+"deg)"; document.getElementById("lights").appendChild(bulb); } </script> </body> </html>
thumb

CSS Videos

Animation Rigging

Holiday Christmas Lights Animation Tutorial CSS JavaScriptParallax Effect Animation Multiple Background CSS TutorialBackground Position keyframes Animation CSS TutorialFolding Content Nav Menu CSS3 Animation JavaScript TutorialPure CSS Animated Menu Button Transitionskeyframes Animation Tutorial Floating ElementsAnimated Repeating Tile Background keyframes TutorialFlip 3D Boxes and Cards Animation CSS TutorialFlash and Pulse Effects keyframes Animation TutorialImage Zoom Effect Animation CSS3 HTML Tutorial