Detailed example of 3D flop effect of css3 special effects
this article mainly introduces the 3d flop effect of css3 special effects. it has certain reference value. interested friends can refer to it. i hope it will be useful to you. help!
i have been learning css3 recently and found that he is really getting better and better. today's css3 is no longer the previous css, and the functional effects it can produce are beyond our imagination. it can implement flash, can create some effects that can be produced by js, and can also write some effects such as gradients, rounded corners, shadows, etc. made by ps. it is so dazzling that i believe many people have already done it. let’s study it more deeply, haha. i also studied it a little today, mainly about some of its 3d effects. i have never been unclear about 3d. i just have time to study it today. .
the so-called 3d flop effect is actually two pictures, one picture is in front and one picture is in the back. when the picture in front is rotated, when it is turned to a certain angle, the picture behind it will rotate with its pace. it is just that one of the pictures is rotated until it is invisible, and the other picture is just about to turn. you can see it. are you impatient? come and learn with me, haha~@@@
first of all, we have such a layout in html:
<p class="outer"> <p class="p1"></p> <p class="p2"></p> </p>
don't underestimate the p outside, it but this content is indispensable. without it, the subsequent effects cannot be achieved! after the layout is laid out, the next step is to start working on the style. the first thing to do is definitely the outside. give it a width and height. you can decide it yourself. i will give it a width and height of 200*200 first. now that the outside stuff is done, the inside stuff is about to start. here we give 200*200. at this time, when i look in the browser, i find that p1 and p2 are displayed up and down, one up and one down. this is correct. you must know that p is a block element and it takes up a whole line, but this is not true for what we said before. there must be a contradiction between the front and back. don't worry, give it an absolute position: absolute; so that the centers of the two p's coincide. in order to distinguish the two p's, here we have to give them different background colors. the preliminary preparation work is almost done, now let’s see how to achieve the effect!
we are trying to achieve a flop effect. as soon as you hear it, you will know that there must be rotation. yes, this requires the use of the new attribute transform:rotatey(?deg) in css3; some people may ask why it is rotatey, but you don’t know. flip, of course, rotates along the y axis. ha ha! so when the mouse moves to p, we have to let it achieve the rotation effect. then the use of the outer p comes. no matter which small p is used, they cannot rotate at the same time unless our mouse is clicked outside. on that p, there is this code,
.outer:hover .p1{ transform:rotatey(-180deg); } .outer:hover .p2{ transform:rotatey(0deg); }
rotation is there, but rotation without any transition effect looks ugly, so here, we have to give them a transition effect , you need to use the new attributes in css3transition:all 2s; all here means that all its effects are transitioned. speaking of this, we have actually not dealt with one thing, that is, how to rotate the current one to the back, and the latter one will appear immediately after it. this is backface-visibility:hidden; a very important attribute in image transformation. , it means that when the picture moves to an invisible place on the display screen, it disappears. that is to say, we can see it when it is originally front-facing, but when it rotates 180 degrees along the y-axis, we can no longer see it. if we do not add this attribute, we can see the reverse image after rotation. it will no longer be visible. so we're going to add this attribute to the two small p's. and in order to achieve this effect, we have to make one of the two small p's not rotated at the beginning. we can see that the other one, which is the one behind, is rotated 180 degrees, so that when the first p starts to rotate, we you will not see the second p immediately, but wait until it rotates to a place where it cannot be seen, and then the second p will appear. the specific code is as follows:
<html><head> <title>3D翻牌效果 </title> <meta charset="UTF-8"> <script type="text/javascript" src="jquery.js"></script> <style type="text/css"> .outer{ width: 510px; height: 340px; border: 1px red solid; margin: 0 auto; } .outer p{ width:510px; height: 340px; position: absolute; transform-style: preserve-3d; backface-visibility:hidden; transition:all 2s; } .p1{ background: url("images/1.jpg"); transform:rotateY(0); } .p2{ background: url("images/2.jpg") no-repeat; transform:rotateY(-180deg); } .outer:hover .p1{ transform:rotateY(-180deg); } .outer:hover .p2{ transform:rotateY(0deg); } </style></head><body><p class="outer"> <p class="p1"></p> <p class="p2"></p></p></body></html>
the above is the main content of this article, i hope it can help everyone.
【recommended tutorials】
1. css video tutorial
2. css online manual
3. bootstrap tutorial

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

How to achieve wave effect with pure CSS3? This article will introduce to you how to use SVG and CSS animation to create wave effects. I hope it will be helpful to you!

This article will show you how to use CSS to easily realize various weird-shaped buttons that appear frequently. I hope it will be helpful to you!

Two methods: 1. Using the display attribute, just add the "display:none;" style to the element. 2. Use the position and top attributes to set the absolute positioning of the element to hide the element. Just add the "position:absolute;top:-9999px;" style to the element.

In CSS, you can use the border-image attribute to achieve a lace border. The border-image attribute can use images to create borders, that is, add a background image to the border. You only need to specify the background image as a lace style; the syntax "border-image: url (image path) offsets the image border width inward. Whether outset is repeated;".

Implementation method: 1. Use the ":active" selector to select the state of the mouse click on the picture; 2. Use the transform attribute and scale() function to achieve the picture magnification effect, the syntax "img:active {transform: scale(x-axis magnification, y Axis magnification);}".

How to create text carousel and image carousel? The first thing everyone thinks of is whether to use js. In fact, text carousel and image carousel can also be realized using pure CSS. Let’s take a look at the implementation method. I hope it will be helpful to everyone!

In CSS3, you can use the "animation-timing-function" attribute to set the animation rotation speed. This attribute is used to specify how the animation will complete a cycle and set the speed curve of the animation. The syntax is "element {animation-timing-function: speed attribute value;}".

The animation effect in css3 has deformation; you can use "animation: animation attribute @keyframes ..{..{transform: transformation attribute}}" to achieve deformation animation effect. The animation attribute is used to set the animation style, and the transform attribute is used to set the deformation style. .
