Technicalarticles
使用JavaScript
使用CSS
<!DOCTYPE html><html><head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <title> How to Zoom an Image on Mouse Hover using CSS? </title> </head> <body> <div> <img src="https://media.geeksforgeeks.org/wp-content/uploads/20200403151026/adblur_gfg.png" alt="Geeks Image" /> </div> </body> </html>
<style>
.geeks {
width: 300px;
height: 300px;
overflow: hidden;
margin: 0 auto;
}
.geeks img {
width: 100%;
transition: 0.5s all ease-in-out;
}
.geeks:hover img {
transform: scale(1.5);
}
</style>
<!DOCTYPE html><html><head> <meta charset="UTF-8" /> <meta name="viewport" content= "width=device-width, initial-scale=1.0" /> <title> How to Zoom an Image on Mouse Hover using CSS? </title> <style> .geeks { width: 300px; height: 300px; overflow: hidden; margin: 0 auto; } .geeks img { width: 100%; transition: 0.5s all ease-in-out; } .geeks:hover img { transform: scale(1.5); }</style></head><body> <div class="geeks"> <img src="https://media.geeksforgeeks.org/wp-content/uploads/20200403151026/adblur_gfg.png" alt="Geeks Image" /> </div></body></html>
DO U LIKE?