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
- ipad
- CSS
- button
- xcode
- iPhone
- effect
- HTML
- javascript
- 풀스택
- 자바스크립트
- iOS 개발자
- 프론트엔드
- front-end
- 백엔드
- hover
- 비전공 개발자
- IOS
- css3
- MAC
- image
- react
- jQuery
- SWIFT
- Animation
- 개발자
- 애니메이션
- html5
- 비전공자
- keyframes
- php
Archives
- Today
- Total
비전공자 개발일기
Scroll Animation 본문
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>SCROLL ANIMATION</title>
<link rel="stylesheet" href="style.css">
<script defer src="main.js"></script>
</head>
<body>
<h1>Scroll to see the animation</h1>
<div class="box">
<h2>Content</h2>
</div>
<div class="box">
<h2>Content</h2>
</div>
<div class="box">
<h2>Content</h2>
</div>
<div class="box">
<h2>Content</h2>
</div>
<div class="box">
<h2>Content</h2>
</div>
<div class="box">
<h2>Content</h2>
</div>
<div class="box">
<h2>Content</h2>
</div>
<div class="box">
<h2>Content</h2>
</div>
<div class="box">
<h2>Content</h2>
</div>
<div class="box">
<h2>Content</h2>
</div>
</body>
</html>
* {
box-sizing: border-box;
}
body {
background-color: #EFEDD6;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
margin: 0;
overflow-x: hidden;
}
h1 {
margin: 10px;
}
.box {
background-color: #9535F0;
color: #FFF;
display: flex;
align-items: center;
justify-content: center;
width: 70%;
height: 200px;
margin: 10px;
border-radius: 10px;
box-shadow: 0 3px 12px #9535F0;
transform: translateX(400%);
transition: transform .8s ease;
}
.box:nth-of-type(even) {
transform: translateX(-400%);
}
.box.show {
transform: translateX(0);
}
.box h2 {
font-size: 45px;
}
const boxes = document.querySelectorAll(".box");
const checkBoxes = () => {
const triggerBottom = (window.innerHeight / 5) * 4;
boxes.forEach((box) => {
const boxTop = box.getBoundingClientRect().top;
if(boxTop < triggerBottom) box.classList.add("show");
else box.classList.remove("show");
});
};
window.addEventListener("scroll", checkBoxes);
checkBoxes()
728x90
LIST
'HTML _CSS' 카테고리의 다른 글
Project Management Dashboard (0) | 2022.06.22 |
---|---|
Sliding Card UI Design (0) | 2022.06.19 |
Mobile Battery percentage Check (0) | 2022.06.16 |
CSS Input Text Field Animation (0) | 2022.06.14 |
Reavl Text Animation (0) | 2022.06.13 |