javascript - Reduce the space between two canvas html - Stack Overflow

I am trying to place two canvas nearby. But unfortunately when i include two canvas it automatically pr

I am trying to place two canvas nearby. But unfortunately when i include two canvas it automatically produces a space between two canvas. How to remove that empty space or how to join that two canvas. Here is my fiddle Fiddle

here is my code:

<canvas id="button" width="30" height="30" style="border:1px solid #d3d3d3;background-color:green;"></canvas> 
<canvas id="button" width="30" height="30" style="border:1px solid #d3d3d3;background-color:green;"></canvas> 
​

here is the script:

window.onload=function()
{
var canvas = document.getElementById("button");
var ctx = canvas.getContext('2d');
}​

I am trying to place two canvas nearby. But unfortunately when i include two canvas it automatically produces a space between two canvas. How to remove that empty space or how to join that two canvas. Here is my fiddle Fiddle

here is my code:

<canvas id="button" width="30" height="30" style="border:1px solid #d3d3d3;background-color:green;"></canvas> 
<canvas id="button" width="30" height="30" style="border:1px solid #d3d3d3;background-color:green;"></canvas> 
​

here is the script:

window.onload=function()
{
var canvas = document.getElementById("button");
var ctx = canvas.getContext('2d');
}​
Share Improve this question asked Dec 19, 2012 at 3:55 Praveen SinghPraveen Singh 5422 gold badges10 silver badges23 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 8

The newline in the HTML is being treated as a space. Simply get rid of the whitespace between the two canvases:

<canvas id="button" width="30" height="30" style="border:1px solid #d3d3d3;background-color:green;">
</canvas><canvas id="button" width="30" height="30" style="border:1px solid #d3d3d3;background-color:green;">
</canvas>

See fiddle.

Or use:

<canvas id="button" width="30" height="30" style="border:1px solid #d3d3d3;background-color:green;"></canvas><!--
--><canvas id="button" width="30" height="30" style="border:1px solid #d3d3d3;background-color:green;"></canvas>

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745290004a4620799.html

相关推荐

  • javascript - Reduce the space between two canvas html - Stack Overflow

    I am trying to place two canvas nearby. But unfortunately when i include two canvas it automatically pr

    4小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信