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
- jQuery
- CSS
- image
- 자바스크립트
- 비전공 개발자
- php
- html5
- iPhone
- IOS
- MAC
- SWIFT
- 비전공자
- iOS 개발자
- 애니메이션
- javascript
- effect
- hover
- Animation
- css3
- xcode
- 풀스택
- ipad
- react
- 개발자
- HTML
- 프론트엔드
- keyframes
- 백엔드
- front-end
- button
Archives
- Today
- Total
비전공자 개발일기
Abstract BG Generator with anime.js 본문
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>ABSTRACT BG GENERATOR</title>
<link rel="stylesheet" href="style.css">
<script defer src="main.js"></script>
<script src="anime.min.js"></script>
</head>
<body>
<div class="container">
<button class="btnAni">Generate</button>
</div>
</body>
</html>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
background-color: #202020;
overflow: hidden;
}
.container {
position: absolute;
width: 100%;
height: 100%;
display: flex;
justify-content: center;
align-items: center;
}
button {
position: relative;
z-index: 1;
margin: 10px;
border: none;
outline: none;
background-color: #FFF;
font-size: 1.2em;
padding: 15px 30px;
cursor: pointer;
box-shadow: 10px 10px 30px rgba(0, 0, 0, .25);
/* display: none; */
}
.block {
position: absolute;
width: 50px;
height: 50px;
background-color: #FFF;
box-shadow: 10px 10px 30px rgba(0, 0, 0, .25);
}
.block:nth-child(3n + 2) {
background-color: #444;
}
.block:nth-child(3n + 3) {
background-color: #FF9213;
}
const container = document.querySelector(".container");
for (let i = 1; i <= 100; i++) {
const blocks = document.createElement("div");
blocks.classList.add("block");
container.appendChild(blocks);
}
function generate() {
anime({
targets: ".block",
translateX: function () {
return anime.random(-700, 700);
},
translateY: function () {
return anime.random(-700, 700);
},
scale: function () {
return anime.random(1, 5);
},
});
}
const btn = document.querySelector(".btnAni");
btn.addEventListener("click", generate);
728x90
LIST
'HTML _CSS' 카테고리의 다른 글
Unfold CSS Effect (0) | 2022.10.27 |
---|---|
SOLAR Eclipse (0) | 2022.10.26 |
Light 3D Cube (0) | 2022.10.24 |
Candle Animation (0) | 2022.10.22 |
Box Card Hover Effects (0) | 2022.10.21 |