Ⅰ. 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 As we all know, by default, the MySQL ins...
Table of contents Preface 1. Install NJS module M...
This error is often encountered by novices. This ...
When exporting data to operations, it is inevitab...
Specific method: Step 1: Stop the mysql service /...
The article mainly records the simple installatio...
Use of built-in functions in the database This ar...
1. CDN It is the most commonly used acceleration ...
Table of contents Load Balancing Load balancing c...
1. Turn off the firewall and transfer the softwar...
Table of contents Matlab Centroid Algorithm As a ...
The most important thing for idea to package a we...
Setting the font for the entire site has always b...
Table of contents Create a vue + ts project using...
Today I will share with you a breathing carousel ...