How can I connect two HTML elements by drawing lines in a background canvas?

后端 未结 1 1068
情歌与酒
情歌与酒 2021-01-13 02:02

Probably more of a math question, but here it goes...

What I want to do is two HTML elements to be connected by an animated line on a background canvas

Here

相关标签:
1条回答
  • 2021-01-13 02:19

    I have found out the reason of the missplacement of the lines.

    It seems like that CSS width and height of canvas is completely different than the actual width and height of the canvas element. So if you wish to make the coordinates of the HTML elements match the coordinates of the lines on the Canvas element, you need to set fixed width on the div that contains it and the same and fixed width and height, directly on the element

    Here is the fixed example so you can have a look:

    http://jsfiddle.net/loupax/zUqXn/29/

    0 讨论(0)
提交回复
热议问题