简体   繁体   English

HTML5画布大小可覆盖整个html页面

[英]HTML5 Canvas Size to Span the whole html page

I recently learnt JavaScript and decided to go ahead and implement a page for Github. 我最近学习了JavaScript,并决定继续为Github实施一个页面。 Everything looks fine but the only problem I face is that the JS code for canvas doesn't scale the full html page, meaning the particles bounce off from the initial window and when I scroll down, that space remains devoid of any particles. 一切看起来都很好,但我面临的唯一问题是画布的JS代码无法缩放整个html页面,这意味着粒子从初始窗口弹回,当我向下滚动时,该空间仍然没有任何粒子。 I want the JS canvas to have particles all over the page. 我希望JS画布在整个页面上都有粒子。 Can someone help me as to how I can go about fixing it? 有人可以帮我解决该问题吗?

TLDR: How can I fix the JS code so that the particle effect span the whole html page rather than just the initial window leaving everything else devoid? TLDR:如何修复JS代码,使粒子效果跨越整个html页面,而不仅仅是初始窗口,而其他所有东西都不存在?

https://devkapupara.github.io/ Relevant file: https://github.com/devkapupara/devkapupara.github.io https://devkapupara.github.io/相关文件: https : //github.com/devkapupara/devkapupara.github.io

This sounds like an html/css issue, not a js issue. 这听起来像是html / css问题,而不是js问题。 Even if you assign your element 100% width, the body of your template may have built in padding. 即使将元素的宽度指定为100%,模板的主体也可能内置了填充。 Try the following: 请尝试以下操作:

<!-- HTML -->

<div id="my-canvas-container">
  <!-- this is where your canvas would load -->
</div>



/* CSS */

html, body {
  padding: 0;
  margin: 0;
}

#my-canvas-container {
  min-width:100%
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM