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
- react
- SWIFT
- front-end
- MAC
- HTML
- html5
- 자바스크립트
- keyframes
- image
- xcode
- 풀스택
- php
- javascript
- 프론트엔드
- Animation
- 비전공자
- 애니메이션
- IOS
- iPhone
- 개발자
- css3
- button
- effect
- 비전공 개발자
- CSS
- ipad
- iOS 개발자
- hover
- jQuery
- 백엔드
Archives
- Today
- Total
비전공자 개발일기
Page Flip 본문
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>PAGE FLIP</title>
<link rel="stylesheet" href="style.css">
<script defer src="main.js"></script>
</head>
<body>
<section>
<div class="left next"></div>
<div class="right next"></div>
<div class="left current"></div>
<div class="right current"></div>
</section>
<h1 id="title">tap the image to flip</h1>
</body>
</html>
:root {
--duration: 500ms;
--ease-in: cubic-bezier(0.85, 0, 1, 1);
--ease-out: cubic-bezier(0, 0, 0.3, 1);
--ease-in-out: ease-in-out;
--image-current: url(https://images.unsplash.com/photo-1630847911146-edd8828abf14?crop=entropy&cs=srgb&fm=jpg&ixid=MnwxNDU4OXwwfDF8cmFuZG9tfHx8fHx8fHx8MTYzMjUxMjQ0Ng&ixlib=rb-1.2.1&q=85);
--image-next: url(https://images.unsplash.com/photo-1596774468032-915cdd39ea39?crop=entropy&cs=srgb&fm=jpg&ixid=MnwxNDU4OXwwfDF8cmFuZG9tfHx8fHx8fHx8MTYzMjUxMjg1MQ&ixlib=rb-1.2.1&q=85);
}
html, body, section {
height: 100%;
}
@keyframes zoom-1 {
0%, 100% { transform: scale(0.8); }
50% { transform: scale(0.75); box-shadow: 0 1vh 3vh rgba(0, 0, 0, 0.1); }
}
@keyframes zoom-2 {
0%, 100% { transform: scale(0.8); }
50% { transform: scale(0.75); box-shadow: 0 1vh 3vh rgba(0, 0, 0, 0.1); }
}
section {
animation: zoom-1 calc(var(--duration) * 2) var(--ease-in-out);
border-radius: 1vh;
box-shadow: 0 2vh 4vh rgba(0, 0, 0, 0.2);
display: flex;
perspective: 2000px;
position: relative;
transform: scale(0.8);
width: 100%;
}
/* duplicating the animation to get it to fire again */
section.flip {
animation: zoom-2 calc(var(--duration) * 2) var(--ease-in-out);
}
.left,
.right {
backface-visibility: hidden;
background-attachment: fixed;
background-position: center center;
background-size: cover;
height: 100%;
position: absolute;
top: 0;
transition-property: transform;
transition-duration: var(--duration);
width: 50%;
}
.current {
background-image: var(--image-current);
}
.next {
background-image: var(--image-next);
}
.left {
border-radius: 1vh 0 0 1vh;
left: 0;
transform-origin: 100% 50%;
}
.right {
border-radius: 0 1vh 1vh 0;
right: 0;
transform-origin: 0% 50%;
}
.next.left {
transform: rotateY(90deg);
transition-delay: 0ms;
transition-timing-function: var(--ease-in);
z-index: 9;
}
.current.right {
transform: rotateY(0deg);
transition-delay: var(--duration);
transition-timing-function: var(--ease-out);
}
.flip .current.right {
transform: rotateY(-90deg);
transition-delay: 0ms;
transition-timing-function: var(--ease-in);
}
.flip .next.left {
transform: rotateY(0deg);
transition-delay: var(--duration);
transition-timing-function: var(--ease-out);
}
h1 {
bottom: 3vh;
font-size: 2vh;
left: 0;
position: absolute;
text-align: center;
transition: opacity 500ms var(--ease-out);
width: 100%;
}
const section = document.querySelector("section");
let clicked = false;
section.addEventListener("click", (e) => {
section.classList.toggle("flip");
if (!clicked) {
clicked = true;
document.getElementById("title").style.opacity = 0;
}
});
728x90
LIST
'HTML _CSS' 카테고리의 다른 글
Eye Follow Mouse Cursor (0) | 2022.10.12 |
---|---|
Hover Menu Text (0) | 2022.10.08 |
Animated Radial Menu (0) | 2022.10.02 |
Image Check (0) | 2022.10.01 |
Cube Hover (0) | 2022.09.30 |