Implementation of css transform page turning animation record

Implementation of css transform page turning animation record

Page turning problem scenario

B and C are on the same page (front and back)

When you want to turn the page to cover A, B and C need to turn the page at the same time to cover A and display D.

B and C cannot be written in the same box

Wrong example:

<div class="pagesBox A"></div>
<div class="pagesBox">
  <div class="B"></div>
  <div class="C"></div>
</div>
<div class="pagesBox D"></div>

Correct example:

<main>
  <div class="pagesBox A"></div>
  
  <div class="pagesBox B"></div>
  <div class="pagesBox C">
    <div>content</div>
  </div>

  <div class="pagesBox D"></div>
</main>

Why not use a box to wrap B and C and just flip them over?

The answer is below.

B Need to set

.B{
  backface-visibility: hidden;
}

backface-visibility: hidden; This property makes the back of B hidden .

And let B and C overlap, using absolute positioning to overlap.

C needs to be set

.C > div{
  transform: rotateY(-180deg);
}

Because the normal content is displayed on the front side, we need to flip the content of C to the back side. Make it look like the back of the paper

Back to the question above, why not use a box

Because when the box containing B and C is turned over, setting B to hide the back is invalid. Only by turning B over can the back of B be hidden. Showing the C on the back.

Then, the pages of B and C are turned with animation.

main{
  perspective: 1800;
  transform-style: preserve-3d;
}

.B,.C{
  transition: transform 1s;
  
  &.On{
    transform: rotateY(180deg);
  }
}

This is the end of this article about the implementation of CSS transform page turning animation record. For more relevant CSS page turning animation content, please search 123WORDPRESS.COM's previous articles or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future!

<<:  Comment reply pop-up mask effect implementation idea compatible with ie 8/chrome/firefox

>>:  Share 20 JavaScript one-line codes

Recommend

Solution to the MySQL error "Every derived table must have its own alias"

MySQL reports an error when executing multi-table...

Complete steps to quickly configure HugePages under Linux system

Preface Regarding HugePages and Oracle database o...

How to dynamically modify container port mapping in Docker

Preface: Docker port mapping is often done by map...

Using vue3 to imitate the side message prompt effect of Apple system

Table of contents Animation Preview Other UI Libr...

JavaScript lazy loading detailed explanation

Table of contents Lazy Loading CSS styles: HTML p...

Causes and solutions for slow MySQL queries

There are many reasons for slow query speed, the ...

Example of how to create a local user in mysql and grant database permissions

Preface When you install MySQL, you usually creat...

Advantages of INSERT INTO SET in MySQL

Insert data into mysql database. Previously commo...

Analysis of the differences between Iframe and FRAME

1. Use of Iframe tag <br />When it comes to ...

The DOCTYPE mode selection mechanism of well-known browsers

Document Scope This article covers mode switching...

Processing ideas for decrypting WeChat applet packages on PC in node.js

Table of contents Where is the source code of the...

Summary of using the exclamation mark command (!) in Linux

Preface Recently, our company has configured mbp,...

MySQL complete collapse: detailed explanation of query filter conditions

Overview In actual business scenario applications...