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 |
Tags
- SWIFT
- front-end
- iOS 개발자
- Animation
- button
- jQuery
- 프론트엔드
- MAC
- iPhone
- javascript
- keyframes
- ipad
- IOS
- html5
- hover
- 자바스크립트
- xcode
- php
- react
- CSS
- 백엔드
- 풀스택
- 애니메이션
- css3
- 비전공 개발자
- HTML
- image
- 개발자
- 비전공자
- effect
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 |