javascript - Fullscreen rectangle in Canvas (Android/iOS web app)

前端 未结 2 534
再見小時候
再見小時候 2021-01-22 16:56

I have a problem trying to render a rectangle over the entire browser viewport using Canvas. The code below works fine on desktop, but on mobile devices (tested on iPad mini, Ne

2条回答
  •  爱一瞬间的悲伤
    2021-01-22 17:49

    You might try ensuring that your html and body elements are all the full width and height of the viewport. Include any ancestors between the canvas and body as well. See the following CSS code:

    html,
    body {
      width: 100%;
      height: 100%;
    }
    

提交回复
热议问题