html draw line div

Solutions on MaxInterview for html draw line div by the best coders in the world

showing results for - "html draw line div"
Nais
01 Feb 2017
1
2class CreateLine {
3
4    line;
5
6    constructor(element, element2) {
7        let el1 = this.GetCoord(element);
8        let el2 = this.GetCoord(element2);
9        let x1 = el1[0];
10        let y1 = el1[1];
11        let x2 = el2[0];
12        let y2 = el2[1];
13        let length = Math.sqrt(((x2 - x1) * (x2 - x1)) + ((y2 - y1) * (y2 - y1)));
14        let cx = ((x1 + x2) / 2) - (length / 2);
15        let cy = ((y1 + y2) / 2) - (1 / 2);
16        let deg = Math.atan2((y1 - y2), (x1 - x2)) * (180 / Math.PI);
17        let line = document.createElement("div");
18        line.style.left = cx + "px";
19        line.style.top = cy + "px";
20        line.style.width = length + "px";
21        line.style.transform = "rotate(" + deg + "deg)";
22        this.line = line;
23    }
24
25    GetLine() {
26        return this.line;
27    }
28
29    GetCoord(element, top = true) {
30        let x = element.offsetLeft;
31        let y = element.offsetTop;
32        return [x, y];
33    }
34
35}
queries leading to this page
line between two divs cssdraw line between divdraw line in css use between divscss line between two divshow to draw a line html csshow to draw a line between div in htmljs draw line between two divscss html draw line between two divs middlehow to draw a line between two divs in htmldraw line between two divs javascripthow to draw a line between divsdraw line between divsdraw a line in a divcss draw lines between divsjavascript draw line between two divsdraw line between two divs dynamicallyhow to draw line in cssdraw line between two div cssdraw a line between two divscss draw line between two elementsdraw line in div tag javascripthtml css draw line between divshtml draw a line between 2 divscss draw line between divsdraw line between two divs cssdraw line between two divdraw line from div to divhtml draw line between divcss draw a line between two divsdraw lines between two elements htmldraw line with divhow to create a line between two divsmake line between two divs in htmlline between two divs in csshow to draw a line in csshtml draw line between two divsdraw line between two divshow to put a line between two divdraw line htmlhow draw line csshow to draw a line between two sections in cssdraw line html5make line between two divsdraw line in csshtml draw line between divshow to make or draw line between two divs in htmldraw responsive line between two divsdynamic css line between two divsdraw line between two elements csscss draw a linehtml css draw line between two divs middlecss draw line through divhtml draw line div