Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/75.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何使元素的宽度和高度达到页面(文档)的100%,而不仅仅是窗口(浏览器)?_Javascript_Html_Css - Fatal编程技术网

Javascript 如何使元素的宽度和高度达到页面(文档)的100%,而不仅仅是窗口(浏览器)?

Javascript 如何使元素的宽度和高度达到页面(文档)的100%,而不仅仅是窗口(浏览器)?,javascript,html,css,Javascript,Html,Css,我有一段代码,它有一个稍微闪烁的动画,我想用它作为背景,但目前它只填充浏览器窗口,我希望它填充整个页面/文档 有人能帮忙吗?我在这儿闲逛- 这是一些内容 更改设置尺寸如下所示: function setDimensions(e) { var body = document.body, html = document.documentElement; WIDTH = window.innerWidth; HEIGHT =

我有一段代码,它有一个稍微闪烁的动画,我想用它作为背景,但目前它只填充浏览器窗口,我希望它填充整个页面/文档

有人能帮忙吗?我在这儿闲逛-


这是一些内容


更改
设置尺寸
如下所示:

    function setDimensions(e) {   
 var body = document.body,
    html = document.documentElement;
            WIDTH = window.innerWidth;
            HEIGHT =  Math.max( body.scrollHeight, body.offsetHeight, 
                       html.clientHeight, html.scrollHeight, html.offsetHeight );
            container.style.width = WIDTH+'px';
            container.style.height = HEIGHT+'px';
            canvas.width = WIDTH;
            canvas.height = HEIGHT;
        }

    function setDimensions(e) {   
 var body = document.body,
    html = document.documentElement;
            WIDTH = window.innerWidth;
            HEIGHT =  Math.max( body.scrollHeight, body.offsetHeight, 
                       html.clientHeight, html.scrollHeight, html.offsetHeight );
            container.style.width = WIDTH+'px';
            container.style.height = HEIGHT+'px';
            canvas.width = WIDTH;
            canvas.height = HEIGHT;
        }