[英]How do I make an element 100% width and height of the page (document) and not just the window (browser)?
我有一段代码,它有一个轻微的闪烁动画,我想用作背景,但目前它只填充浏览器窗口,我希望它填充整个页面/文档。
任何人都可以帮忙吗? JSFiddle在这里 - https://jsfiddle.net/83aahcng/1/
<div id="container">
<canvas id="pixie"></canvas>
<div class="content">
<p>This is some content</p>
</div>
</div>
更改您的setDimensions
如下所示:
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;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.