javascript - Why is the body height 4 pixels more than the canvas height?
扔个三星炸死你
扔个三星炸死你 2017-07-05 10:48:24
0
1
692

css:

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

html:

<canvas id="canvas"></canvas>

javascript:

dt = document.getElementById('canvas');
dt.width = window.innerWidth;
dt.height = window.innerHeight;

The result is like this:

Logically shouldn’t canvas be as high as body? Why does body have 4 extra pixels?
Please tell me, thank you!

扔个三星炸死你
扔个三星炸死你

reply all(1)
我想大声告诉你

Add

to body
body {
    font-size: 0
}

Please see: http://www.w3cplus.com/css/fi...

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template