The problem is: I have a% centralized% with that container trick in div
or position: absolute
and fixed
internal in div
.
As you can see, when the animation is executed, the% s of internal% (#square) grows from top to bottom. I would like it to grow from its center and expand to all sides, but it stays the same distance from the top, because of relative
. What can I do so that, in animation, it expands to all sides, rather than up and down?
// Função simples para animar a div com css transitions
var square = document.querySelector('#square');
setTimeout(function(){
square.style.width = '100px';
square.style.height = '100px';
}, 500);
#container {
position: fixed;
left: 50%;
top: 50%;
}
#square {
position: relative;
left: -50%;
top: -30%;
width: 20px;
height: 20px;
background: blue;
transition: all 1s ease-in-out;
}
<div id="container" >
<div id="square" > </div>
</div>