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

Implementation example of uploading multiple attachments in Vue

Table of contents Preface Core code File shows pa...

Explanation of MySQL performance inspection through show processlist command

The show processlist command is very useful. Some...

LINUX Checks whether the port is occupied

I have never been able to figure out whether the ...

Learn more about the most commonly used JavaScript events

Table of contents JavaScript events: Commonly use...

Using Openlayer in Vue to realize loading animation effect

Note: You cannot use scoped animations! ! ! ! via...

CSS HACK for IE6/IE7/IE8/IE9/FF (summary)

Since I installed the official version of IE8.0, ...

Using jQuery to implement the carousel effect

This article shares the specific code for impleme...

Some tips on speeding up the development of WeChat mini-programs

1. Create a page using app.json According to our ...

26 Commonly Forgotten CSS Tips

This is a collection of commonly used but easily ...

Summary of JavaScript Timer Types

Table of contents 1.setInterval() 2.setTimeout() ...

Detailed Introduction to the MySQL Keyword Distinct

Introduction to the usage of MySQL keyword Distin...

Pure CSS3 mind map style example

Mind Map He probably looks like this: Most of the...

jQuery combined with CSS to achieve the return to top function

CSS Operations CSS $("").css(name|pro|[...

JavaScript to implement input box content prompt and hidden function

Sometimes the input box is small, and you want to...