ADVERTISEMENT

Create Page Flip Animation In HTML , CSS & JavaScript

Telegram Group Join Now

ADVERTISEMENT

Create Page Flip Animation In HTML , CSS & JavaScript

 

ADVERTISEMENT

Create Page Flip Animation In HTML , CSS & JavaScript
Create Page Flip Animation In HTML , CSS & JavaScript

ADVERTISEMENT

 

Welcome to the codewithrandom blog. In this article, We create Page Flip Animation Project. We use Html,Css,and Javascript Code for Page Flip Animation Project.

ADVERTISEMENT

Hope you enjoy our blog so let’s start with a basic html structure for a Page Flip Animation.

ADVERTISEMENT

Code byJake Albaugh
Project DownloadLink Available Below
Language usedHTML, CSS and JavaScript
External link / DependenciesNO
ResponsiveYES
Page Flip Animation Table

Play Unlimited Quiz Of HTML, CSS, and JavaScript – Click Here

HTML Code For Page Flip animation

 <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>  

This is all the code for Page Flip Animation. Now, you can see output without Css and Javascript, then we write Css & Javascript for the Page Flip Animation .

Output page flip animation

ADVERTISEMENT

 Page Flip Animation Using Html & Css
Page Flip Animation Html Code Preview

 

CSS Code For Page Flip Animation

 :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%;  
 }  

Here is our Updated Output Of Page Flip Animation CSS Code.

output

Portfolio Website Using HTML CSS And JAVASCRIPT ( Source Code)

ADVERTISEMENT

Page Flip Animation CSS
Page Flip Animation CSS

 

Javascript Code For Page Flip Animation

 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;  
  }  
 });  

Final output Of Page Flip Animation

ADVERTISEMENT

Create Page Flip Animation In HTML , CSS & JavaScript
Create Page Flip Animation In HTML , CSS & JavaScript
 

50+ Front-end Projects With Source Code | Front-end Projects With Source Code

Now we have completed our javascript section for Page Flip Animation,  Here is our updated output with javascript code. Hope you like the Page Flip animation.

you can see the output video and project screenshots. See our other blogs and gain knowledge in front-end development. Thank you!

In this post, we learn how to create a Page Flip animation using simple HTML & CSS, and javascript. If we made a mistake or any confusion, please drop a comment to reply or help you in easy learning.

Written by – Code With Random/Anki

ADVERTISEMENT

Codepen by – Jake Albaugh

ADVERTISEMENT

Which code editor do you use for this Page Flip Animation coding?

I personally recommend using VS Code Studio, it’s straightforward and easy to use.

ADVERTISEMENT

is this project responsive or not?

YES! this is a responsive project

ADVERTISEMENT

Do you use any external links to create this project?

No!

ADVERTISEMENT

ADVERTISEMENT

Telegram Group Join Now

Share on:

0 thoughts on “Create Page Flip Animation In HTML , CSS & JavaScript”

  1. ADVERTISEMENT

Leave a Comment

ADVERTISEMENT

ADVERTISEMENT

ADVERTISEMENT