Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SVG lines not visible

Tags:

html

css

Fiddle here

<svg version="1.1">
  <line x1="492" y1="503" x2="717" y2="576" stroke="#4A4A4A" stroke-width="2"></line>
  <line x1="500" y1="400" x2="600" y2="400" stroke="#4A4A4A" stroke-width="2"></line>
  <line x1="604.5" y1="539.5" x2="587.5" y2="542.5" stroke="red" stroke-width="2"></line>
  <line x1="604.5" y1="539.5" x2="592.5" y2="527.5" stroke="red" stroke-width="2"></line>
</svg>

If I give x1="0" and y1="0" then the lines become visible. Why is the line not visible in the code above?


1 Answers

Add width and height to svg element (make sure that is big enough to cover your drawing)

<svg version="1.1" width="1000" height="1000">
  <line x1="492" y1="503" x2="717" y2="576" stroke="#4A4A4A" stroke-width="2"></line>
  <line x1="500" y1="400" x2="600" y2="400" stroke="#4A4A4A" stroke-width="2"></line>
  <line x1="604.5" y1="539.5" x2="587.5" y2="542.5" stroke="red" stroke-width="2"></line>
  <line x1="604.5" y1="539.5" x2="592.5" y2="527.5" stroke="red" stroke-width="2"></line>
</svg>

fiddle: https://jsfiddle.net/af5g1d3q/

like image 186
Everettss Avatar answered Sep 20 '25 15:09

Everettss