CSS3 Breathing Particles

Size
2,756 Kb
Views
24,288

How do I make an css3 breathing particles?

These particles seem to breath in a virtual 3d space. I just had some fun with css3 transition and animation.. What is a css3 breathing particles? How do you make a css3 breathing particles? This script and codes were developed by Gianluca Guarini on 04 November 2022, Friday.

CSS3 Breathing Particles Previews

CSS3 Breathing Particles - Script Codes HTML Codes

<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>CSS3 Breathing Particles</title> <link rel="stylesheet" href="css/style.css">
</head>
<body> <ul> </ul> <script src="js/index.js"></script>
</body>
</html>

CSS3 Breathing Particles - Script Codes CSS Codes

html { overflow:hidden; background:-webkit-gradient(radial, 50% 50%, 0, 50% 50%, 960, from(#C0FCFB), to(#999)) no-repeat #999; background: -moz-radial-gradient(50% 50% 0deg,ellipse farthest-corner, #C0FCFB, #999, #999 170%); background: -o-radial-gradient(50% 50%, #C0FCFB, #999); height:100%; } ul li { list-style:none; position:absolute; -moz-transition: all 1s cubic-bezier(0.600, -0.280, 0.735, 0.045); -webkit-transition: all 1s cubic-bezier(0.600, -0.280, 0.735, 0.045); -o-transition: all 1s cubic-bezier(0.600, -0.280, 0.735, 0.045); transition: all 1s cubic-bezier(0.600, -0.280, 0.735, 0.045); border-radius:300px; border:7px solid rgba(240,232,235, 0.1); background:rgba(255,255,255,0.50); }
@-webkit-keyframes pulse { 0% { -webkit-transform: scale(1); }
50% { -webkit-transform: scale(1.1); } 100% { -webkit-transform: scale(1); }
}
@-moz-keyframes pulse { 0% { -moz-transform: scale(1); }
50% { -moz-transform: scale(1.1); } 100% { -moz-transform: scale(1); }
}
@-o-keyframes pulse { 0% { -o-transform: scale(1); }
50% { -o-transform: scale(1.1); } 100% { -o-transform: scale(1); }
}
@keyframes pulse { 0% { transform: scale(1); }
50% { transform: scale(1.1); } 100% { transform: scale(1); }
}

CSS3 Breathing Particles - Script Codes JS Codes

// Global Vars var ul = document.querySelector("ul"), list = document.createDocumentFragment(), w = window, particles = 60, domPrefixes = 'Webkit Moz O ms Khtml'.split(' '), animationstring = 'animation', pfx = '';
var getAnimationString = function () { for( var i = 0; i < domPrefixes.length; i++ ) { if( ul.style[ domPrefixes[i] + 'AnimationName' ] !== undefined ) { pfx = domPrefixes[ i ]; return animationstring = pfx + 'Animation'; } }
}; // this function changes the inline style of the argument passed var setElementStyle = function (elm) { // setting the syle of the element randomly (note the use of the double tilde to round the numbers) var size = ~~(Math.random() * 150), position = { x: ~~(Math.random() * w.innerWidth) - (size / 2), y: ~~(Math.random() * w.innerHeight) - (size / 2), }; elm.style.width = elm.style.height = size + "px"; elm.style.top = position.y + "px"; elm.style.left = position.x + "px"; elm.style[getAnimationString()] = "pulse "+ ~~(Math.random() * 3) * 3 + "s infinite"; elm.style[pfx+"Transition"] = "all "+ ~~(Math.random() * 3) + 3 +"s cubic-bezier(0.600, -0.280, 0.735, 0.045) "+ ~~(Math.random() *3) + "s"; return elm; }; // changing the inline style of all the li in this page var moveElements = function () { var liArray = document.querySelectorAll("li"), i = liArray.length; while (i --) { setElementStyle(liArray[i]); } }; // this function initializes the example appending the particles to the DOM var init = function (){ while (particles --) { var newLi = document.createElement("li"); list.appendChild(setElementStyle(newLi)); } ul.appendChild(list); }; // let's rock this party init(); // Event Handlers w.addEventListener("resize",moveElements); w.addEventListener("click",moveElements); w.addEventListener("touchstart",moveElements);
CSS3 Breathing Particles - Script Codes
CSS3 Breathing Particles - Script Codes
Home Page Home
Developer Gianluca Guarini
Username GianlucaGuarini
Uploaded November 04, 2022
Rating 3
Size 2,756 Kb
Views 24,288
Do you need developer help for CSS3 Breathing Particles?

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!

Gianluca Guarini (GianlucaGuarini) Script Codes
Create amazing video scripts 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!