0

I want to draw a line on HTML web page dynamically to connect two html elements, which can move on html page. This action is something like connect two Rectangle's angle, like this:

Is there any way to achieve this?

sandyX
  • 137
  • 10
  • 1
    Need more details, what do you mean by 'connect 2 html elements'? Generally you use canvas for Drawing purposes. – Gurpreet Singh Sep 09 '13 at 12:56
  • If you'd rather use CSS than HTML5 canvas, then [this](http://stackoverflow.com/q/4270485/21727) is your duplicate. – mbeckish Sep 09 '13 at 20:34

2 Answers2

0

You may want to look at this tutorial. This tutorial teach you how to draw lines by HTML Canvas API.

HTML5 Canvas Line Tutorial

To draw a line using HTML5 Canvas, we can use the beginPath(), moveTo(), lineTo(), and stroke() methods.

First, we can use the beginPath() method to declare that we are about to draw a new path. Next, we can use the moveTo() method to position the context point (i.e. drawing cursor), and then use the lineTo() method to draw a straight line from the starting position to a new position. Finally, to make the line visible, we can apply a stroke to the line using stroke(). Unless otherwise specified, the stroke color is defaulted to black.

http://www.html5canvastutorials.com/tutorials/html5-canvas-lines/

crzyonez777
  • 1,789
  • 4
  • 18
  • 27
-3

You could use the HTML5 canvas but you will have to be more specific with your question so we can help you further.