-2

Imagine having a box

a          b
 ----------
|          |
|          |
c----------d

The box have point a,b,c and d. I need to have a line from point b to point c, and I will have my data lets say 100% in point a and point d.

is this possible? I tried to look using fr but I still have the problem of drawing a line

Vian Ojeda Garcia
  • 827
  • 4
  • 17
  • 34
  • Vian, you can make this work using an svg. It will be responsive based on the width and height of the container. You can style the path element to have the proper color and stroke thickness. If that sounds like what you need, say so and I'll add an answer with code for that solution. – JasonB Mar 08 '19 at 01:50
  • That might work. Please add this answer, I think this is the better option – Vian Ojeda Garcia Mar 11 '19 at 05:11

1 Answers1

0

You have to make some calculations to connect a line perfectly...

.test{
  width:50vw;
  height:40vw;
  border:2px solid #000;
  position:relative;
}
.test::after{
  content:"";
  position:absolute;
  top:50%;
  left:50%;
  /*get the slope (y/x)*/
  /* here 40/50 = 4/5 ... arctan(4/5) = 0.67 radian  */
  transform:translate(-50%,-50%) rotate(-0.67rad);
  height:2px;
  /* calculate the width of the line (width^2 + height^2)^(1/2) */
  /* width = 64.0312423743 */
  width:64vw;
  background:#000;
}
<div class="test"></div>
xTrimy
  • 804
  • 9
  • 23