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

192
Views
why canvas is not behaving properly?

I want CANVAS (gray part) to always cover the screen.
But it covers too much.
What to do?
(I don't want to use CSS)

resize();

function resize() {
  document.getElementById("can").style.width = window.innerWidth + "px";
  document.getElementById("can").style.height = window.innerHeight + "px";
}
body {
  margin: 0;
  padding: 0;
}

#can {
  margin: 0;
  padding: 0;
  background-color: #eee;
}
<body onresize="resize();">
  <canvas id="can" />
</body>

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

0

You need to add display: block; css to your canvas.

resize();

function resize() {
  document.getElementById("can").style.width = window.innerWidth + "px";
  document.getElementById("can").style.height = window.innerHeight + "px";
}

window.addEventListener('resize', resize);
body {
  margin: 0;
  padding: 0;
}

#can {
  display: block;
  margin: 0;
  padding: 0;
  background-color: #eee;
}
<canvas id="can" />

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!