const app = document.querySelector('#app') const test = document.querySelector('#test') test.onclick = function(){ app.style.display=app.style.display==='block'?'none':'block' const height = app.offsetHeight; console.log(height) app.style.transform= 'translateX(250px)' }
<div id="app"> </div> <button id="test">测试</button>
#app { width: 200px; height: 200px; background-color: red; display: none; transition: all 1s; }