Ⅰ. Problem description:Use CSS to achieve 3D convex and concave effect of pictures; ⅡThe implementation process is as follows: 1. The display results are: B. The image 1 is protruding out of the frame, while the image 2 is normal; C. Picture 1 is normal, Picture 2 is sunken into the frame; 2. Run the software VScode , and it can be realized by personal test; 3. Run the code: <!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8"> <title></title> <style> .wrap { float: left; width: 200px; height: 300px; border: 1px solid red; margin: 100px 0 0 100px; perspective:500px; /* "perspective:500px;" means: perspective distance (effect of small things in the distance and large things near); But only the feeling has changed, and the actual size has not changed; */ } .wrap img { transition: 0.5s; } .wrap:nth-child(1):hover img { transform: translateZ(100px); /* "translateZ(100px);" means: translate 100px in the positive direction of the Z axis (vertical to the outside of the screen is positive); */ } .wrap:nth-child(2):hover img { transform: translateZ(-100px); /* "translateZ(-100px);" means: translate 100px in the negative direction of the Z axis (negative inwards vertically on the screen); */ } </style> </head> <body> <div class="wrap"> <img src="pic02.jpg"/> </div> <!-- The src address in img at this time refers to the address of the image you loaded. When the address of the image and the code document are in the same directory, the address can be simply introduced like the above code; --> <div class="wrap"> <img src="pic02.jpg"/> </div> </body> </html> III. ConclusionThis is the end of this article about how to use CSS to achieve 3D convex and concave effects on images (protruding outside the frame or sunken into the frame). For more relevant content about how to use CSS to achieve 3D convex and concave effects, please search previous articles on 123WORDPRESS.COM or continue to browse the related articles below. I hope you will support 123WORDPRESS.COM in the future! |
<<: How to use React to implement image recognition app
>>: Detailed explanation of the relationship between Linux and GNU systems
Preface Sometimes I feel that the native UI of We...
This article example shares the specific code of ...
This article introduces the method of manually bu...
Table of contents 1. Basics 1.ref 2. toRef 3. toR...
Table of contents 1. What is virtual dom? 2. Why ...
This article shares the specific code of Bootstra...
Date type differences and uses MySQL has five dat...
1. Introduction MySQL comes with a replication so...
In an article a long time ago, I talked about the...
This article shares the specific code of js+Html ...
mysql records time-consuming sql MySQL can record...
After the National Day holiday, did any of you fi...
Table of contents 1. Introduction 2. Principle II...
Today I have nothing to do, so I listed some tool...
First, let's look at an example of memory rel...