html - How to zoom in to a specific point smoothly with CSS? -
i want zoom in onto pencil when hovered on image.
html:
<div> </div>
css:
div { width: 400px; height: 267px; border: 1px solid black; background-image: url('http://i.imgur.com/n9q7jhm.jpg'); background-size: 400px 267px; transition: 1s ease; } div:hover{ background-size: 500px 333px; background-position: -60px -60px; }
jsfiddle: http://jsfiddle.net/ax59y/
my naive attempt increase size , change position of image, can see jsfiddle, transition jagged tries accomplish both transitions @ same time.
is there better way?
take answer sw4 , change left , top changes transform origin
#image { background-image: url('http://i.imgur.com/n9q7jhm.jpg'); background-size: 400px 267px; background-position:center; transition: 1s ease; width:100%; height:100%; transform: scale(1); position:relative; left:0; top:0; -webkit-transform-origin: 75% 75%; transform-origin: 75% 75%; } #wrapper:hover #image { -webkit-transform: scale(2); transform: scale(2); }
the 75% 75% more or less position of pencil , can set whatever want.
Comments
Post a Comment