Answer the question
In order to leave comments, you need to log in
How to animate width and height of div position:absolute?
There is a block, position: absolute
on hover, the width increases,
but if the block has top and left properties, then on hover it increases but also shifts to the right and down.
How to enlarge a block without shifting its center?
Also, what is the right way to specify in css the transition-property width and height so that they increase synchronously,
as with transition-property: all ?
Answer the question
In order to leave comments, you need to log in
transform: scale(N);
UPD
works best for this task :
Change Center can be controlled using transform-origin
Here are the styles for an example, make the necessary changes and use it.
div{top:100px; left:100px; position:absolute; width:100px; height:100px; background:green; transition:0.5s ease all;}
div:hover{width:200px; height:200px; top:50px; left:50px; }
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question