Source code: <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>css to achieve zoom effect when mouse moves in</title> <style type="text/css"> div{ width: 200px; height: 300px; margin:0 auto; margin-top: 100px; } div img{ width: 100%; height: 100%; transition: all 0.6s; //Set the animation execution time to 0.6s cursor: pointer; } div img:hover{ transform: scale(1.2); //Set the image to be enlarged by 1.2 times according to the ratio } </style> </head> <body> <div> <img src="images/unnamed.jpg"> </div> </body> </html> - Mask when the image overflows the div: Source code: <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>css to achieve zoom effect when mouse moves in</title> <style type="text/css"> div{ width: 200px; height: 300px; margin:0 auto; margin-top: 100px; overflow: hidden; //The image is hidden when it exceeds the div } div img{ width: 100%; height: 100%; transition: all 0.6s; //Set the animation execution time to 0.6s cursor: pointer; } div img:hover{ transform: scale(1.3); //Set the image to be enlarged by 1.3 times according to the ratio } </style> </head> <body> <div> <img src="images/unnamed.jpg"> </div> </body> </html> This concludes this article about how to use CSS to achieve image zooming and slow transition effects when the mouse moves over the image. For more information on CSS image zooming when the mouse moves over the image, please search previous articles on 123WORDPRESS.COM or continue browsing the related articles below. We hope that you will support 123WORDPRESS.COM in the future! |
<<: Hello dialog box design experience sharing
>>: Solution to MySQL connection exception and error 10061
1. Environment VS 2019 16.9.0 Preview 1.0 .NET SD...
How to set the position of the block element in t...
Abstract: This article will demonstrate how to se...
Table of contents Uninstall and install samba Cre...
In front-end development, we are in direct contac...
Switching files is a common operation in Linux. W...
1. Two properties of table reset: ①border-collaps...
The steps of docker packaging Python environment ...
Table of contents Hidden Problems Solution to ada...
Conclusion: In a multithreaded environment, if on...
Table of contents 1. Mapped Types 2. Mapping Modi...
Table of contents JavaScript function call classi...
Table of contents Preface Vue update view patch s...
Preface Today, after synchronizing the order data...
1 What is MVCC The full name of MVCC is: Multiver...