<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<style>
.block{
background: lightblue;
transition: all 300ms linear;
width: 0;
height: 0;
}
</style>
</head>
<body>
<div class="block"></div>
<button onclick="toBig()">大</button>
<button onclick="toSmall()">小</button>
<script>
function toBig(){
console.log('tobig')
const block = document.querySelector('.block');
block.style.width='200px'
block.style.height='200px'
}
function toSmall(){
console.log('tosmall')
const block = document.querySelector('.block');
block.style.width='0'
block.style.height='0'
}
</script>
</body>
</html>
transform-origin: center