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/

pencil image

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.

fiddle


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -