Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

211
Views
How to make Canvas fulfilled the page

How I can make Canvas which fulfilled the visible part of page. Everything what I tried give me bigger canvas with scrollbars, or significantly smaller.

<!DOCTYPE html>
<html>
<body>
<p></p>
<canvas id="myCanvas" style="border:1px solid #000000;">
Your browser does not support the canvas element.
</canvas>

<script>
canvasInit();


function canvasInit() {
    var dimension = [document.documentElement.clientWidth, document.documentElement.clientHeight];
    var c = document.getElementById("myCanvas");
    c.width = dimension[0];
    c.height = dimension[1];
}


</script>
</body>
</html>

Page in browser

enter image description here

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

I think something like this should work:

c.width = window.innerWidth * 2;
c.height = window.innerHeight * 2;
c.style.width = `${window.innerWidth}px`;
c.style.height = `${window.innerHeight}px`;
about 4 years ago · Juan Pablo Isaza Report

0

I think you can do this.

set the width like this.

width = window. innerWidth; canvas. height = window. innerHeight;

You could even change it in your javascript

var canvasW     = 640;
var canvasH     = 480;

Even better, you can just put this in your canvasinit() function.

canvas.width = document.body.clientWidth; //document.width is obsolete
canvas.height = document.body.clientHeight; //document.height is obsolete
canvasW = canvas.width;
canvasH = canvas.height;
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!