[英]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.