How to transform image size on mouse hover without affecting the layout in CSS
transform
You can use the CSS transform property to increase or decrease the image size on mouse hover without affecting the surrounding elements or content.
Let's try out the following example to understand how it basically works:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>CSS3 Image Transform Gallery</title> <style> ul { padding: 0; margin: 50px 20px; list-style: none; } ul li { margin: 5px; display: inline-block; } ul li a { padding: 5px; display: inline-block; border: 1px solid #f2f2f2; } ul li a img { width: 125px; height: 125px; display: block; } ul li a:hover img { transform: scale(1.5); box-shadow: 0 0 10px rgba(0, 0, 0, 0.5); } </style> </head> <body> <ul> <li><a href="#"><img src="/examples/images/club.jpg" alt="Club Card"></a></li> <li><a href="#"><img src="/examples/images/diamond.jpg" alt="Diamond Card"></a></li> <li><a href="#"><img src="/examples/images/spade.jpg" alt="Spade Card"></a></li> <li><a href="#"><img src="/examples/images/heart.jpg" alt="Heart Card"></a></li> </ul> </body> </html>
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
Use the CSS
transformpropertyYou can use the CSS
transformproperty to increase or decrease the image size on mouse hover without affecting the surrounding elements or content.Let's try out the following example to understand how it basically works:
need an explanation for this answer? contact us directly to get an explanation for this answer