<body >
<div id="test">
</div>
</body>
<javascript>
function init() {
var totalHeight = window.innerHeight || document.body.clientHeight
var testObj= document.getElementById(‘test‘)
var halfHeight= totalHeight / 2
testObj.style.height = halfHeight+ ‘px‘
}
</javascript>
原文地址:https://www.cnblogs.com/xujuntao/p/12325985.html
时间: 2024-10-13 18:24:50