This time I will bring you the use of CSS3 to implement mouse floating enlargement of images, and the precautions for using CSS3 to implement mouse floating enlargement of images. The following is a practical case, let's take a look.
No need for JS and jQuery code to implement CSS3 mouse floating and enlarging pictures<html> <head> <title></title> <style> .box { /* 可见视觉区域 */ width: 480px; height: 250px; position: relative; overflow: hidden; cursor: pointer; } .size { width: 1000px; height: 1000px; position: absolute; left: 50%; top: 50%; margin: -500px 0 0 -500px; /* 水平居中 */ text-align: center; } .zoom { /* 缩放的元素 */ width: 480px; height: 250px; vertical-align: middle; -webkit-transition: -webkit-transform .2s; transition: transform .2s; } .box:hover .zoom { /* hover放大 */ -webkit-transform: scale(1.05); -ms-transform: scale(1.05); transform: scale(1.05); zoom: 1.05; } :root .box:hover .zoom { zoom: 1; } .middle { /* 垂直居中 */ display: inline-block; width: 0; height: 100%; vertical-align: middle; } </style> </head> <body> <h4>左上角定位</h4> <p class="box"> <img src="dafu.jpg" class="zoom"> </p> <h4>居中定位</h4> <p class="box"> <p class="size"> <img src="dafu.jpg" class="zoom"><i class="middle"></i> </p> </p> </body>
Summary of commonly used color gradient methods
2D simulation to realize special effects of Ferris wheel rotation animation
How to deal with the nth-child() compatibility issue under IE8
How to remove the blur white edge of CSS3
The above is the detailed content of Use CSS3 to implement mouse floating to enlarge pictures. For more information, please follow other related articles on the PHP Chinese website!