250x250
Notice
Recent Posts
Recent Comments
Link
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | 4 | 5 | 6 | |
| 7 | 8 | 9 | 10 | 11 | 12 | 13 |
| 14 | 15 | 16 | 17 | 18 | 19 | 20 |
| 21 | 22 | 23 | 24 | 25 | 26 | 27 |
| 28 | 29 | 30 | 31 |
Tags
- 애니메이션
- 프론트엔드
- effect
- SWIFT
- 풀스택
- 비전공자
- HTML
- 개발자
- Animation
- xcode
- image
- html5
- IOS
- 비전공 개발자
- MAC
- jQuery
- react
- javascript
- front-end
- php
- css3
- button
- iPhone
- hover
- 백엔드
- keyframes
- CSS
- 자바스크립트
- ipad
- iOS 개발자
Archives
- Today
- Total
비전공자 개발일기
Javascript Particles 본문
728x90
SMALL

<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>JAVASCRIPT PARTICLES</title>
<link rel="stylesheet" href="style.css">
<script defer src="main.js"></script>
</head>
<body>
</body>
</html>
* {
margin: 0;
padding: 0;
}
body {
min-height: 100vh;
background-color: #111;
overflow: hidden;
}
span {
position: absolute;
background-color: #F00;
width: 10px;
height: 10px;
pointer-events: none;
border-radius: 50%;
}
span::before {
content: '';
position: absolute;
width: 100%;
height: 100%;
border-radius: 50%;
background-color: #FFF;
animation: moveParticles 2s linear infinite;
}
@keyframes moveParticles {
0% {
transform: translate(0);
}
100% {
transform: translate(300px);
}
}
document.addEventListener('mousemove', function(e) {
let body = document.querySelector('body');
let particles = document.createElement('span');
let x = e.offsetX;
let y = e.offsetY;
particles.style.left = `${x}px`;
particles.style.top = `${y}px`;
let size = Math.random() * 8;
particles.style.width = `${2 + size}px`;
particles.style.height = `${2 + size}px`;
let transformValue = Math.random() * 360;
particles.style.transform = `rotate(${transformValue}deg)`;
body.appendChild(particles);
setTimeout(function() {
particles.remove()
}, 2000)
})728x90
LIST
'Javascript' 카테고리의 다른 글
| QR code Generator (0) | 2022.07.07 |
|---|---|
| Heart Animation Effects (0) | 2022.07.06 |
| Analog Clock (0) | 2022.07.03 |
| Automatic Image Slider (0) | 2022.06.30 |
| Toast Notification (0) | 2022.06.29 |