5
I wanted that when the user passed the cursor over a given image, the image would zoom in a little bit, and that’s all.
5
I wanted that when the user passed the cursor over a given image, the image would zoom in a little bit, and that’s all.
5
Follow the example
img{
width: 100px;
transition: 0.5s;
}
img:hover{
width: 150px;
}
<img src="https://file.iviewui.com/dist/76ecb6e76d2c438065f90cd7f8fa7371.png">
5
It’s pretty simple, you just really need to CSS
. Follow an example:
.grow { transition: all .2s ease-in-out; }
.grow:hover { transform: scale(1.1); }
<img class="grow" src="https://i.stack.imgur.com/oURrw.png" />
In the code snippet above the CSS property transition
has in its value the item .2s
representing the time of the size-increasing effect. To make it more time-consuming just increase this number.
In the next line we have the style applied when passing the mouse over, the trigger :hover
. In it we inform the value of the CSS property transform
with the scale 1.1
. If you want an even bigger size increase, you can change its value to 1.2, 1.3 and so on.
Thank you very much! I will try! :)
Browser other questions tagged html css
You are not signed in. Login or sign up in order to post.
Thanks for the help!
– Vinicius Borges Lima
In this case it is better to use the Transform: Scale, because then the image will be enlarged from the center to the sides. Using width it expands from left side to right and down.
– Maurício Júnior
@Actually it depends on what he needs, there are cases I use
width
and cases that use thetransform: scale
. This varies greatly from need– Rafael Augusto