我想在每次窗口大小更改时重绘元素(重新缩放以适应窗口)。我已经设法根据尺寸制作了适合窗口的代码,但是当我调整窗口大小时,我需要刷新它以重新缩放...
我该怎么做?
窗口.onresize
https://developer.mozilla.org/en/DOM/window.onresize
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
</body>
<script>
window.addEventListener('resize',label,false);
function label(){
document.body.innerHTML=window.innerWidth;
}
</script>
</html>