This article example shares the specific code of js to achieve the star flash effect for your reference. The specific content is as follows The effect is as follows Ideas: 1. Prepare a picture of stars The code is as follows <style> *{ margin: 0; padding: 0; list-style: none; } body{ background-color: #000; } span{ width: 30px; height: 30px; background: url("../images_js/star.png") no-repeat; position: absolute; background-size:100% 100%; animation: flash 1s alternate infinite; } @keyframes flash { 0%{opacity: 0;} 100%{opacity: 1;} } span:hover{ transform: scale(3, 3) rotate(180deg) !important; transition: all 1s; } </style> </head> <body> <script> window.onload = function () { // 1. Find the screen size var screenW = document.documentElement.clientWidth; var screenH = document.documentElement.clientHeight; // 2. Dynamically create stars for(var i=0; i<150; i++){ // 2.1 Create stars var span = document.createElement('span'); document.body.appendChild(span); // 2.2 Random coordinates var x = parseInt(Math.random() * screenW); var y = parseInt(Math.random() * screenH); span.style.left = x + 'px'; span.style.top = y + 'px'; // 2.3 Random scaling var scale = Math.random() * 1.5; span.style.transform = 'scale('+ scale + ', ' + scale + ')'; // 2.4 frequency var rate = Math.random() * 1.5; span.style.animationDelay = rate + 's'; } } </script> The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM. You may also be interested in:
|
<<: Tutorial on installing MySQL 5.7.18 using RPM package
>>: How to build php-nginx-alpine image from scratch in Docker
Table of contents What is React Fiber? Why React ...
What is the input type="file"? I don'...
This article shares the specific code for JavaScr...
** Install mysql-8.0.20 under Linux ** Environmen...
This article example shares the specific code of ...
Table of contents Class component event binding F...
Download opencv.zip Install the dependencies ahea...
When you log in to MySQL remotely, the account yo...
Preface To solve the single point of failure, we ...
Table of contents 1. Route navigation 2. History ...
This article shares the specific implementation c...
Preface lvm (Logical Volume Manager) logical volu...
Sometimes it is necessary to perform simple verif...
After reinstalling my computer recently, I downlo...
Mysql left join is invalid and how to use it When...