2016-05-20 13 views
2

Fiddle hereSVG線見えない

<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> 

Iは、X1 = "0"、Y1 = "0" を与える場合、行が見えるようになります。 上記のコードで行が表示されないのはなぜですか?

+1

あなたの行はおそらく画面領域外です –

答えて

2

フィドル(それがあなたの図面をカバーするのに十分な大きさであることを確認してください)SVG要素に

<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> 

を幅と高さを追加します。あなたのSVGは何のサイズ(すらビューボックス属性)とためを持っていないので、https://jsfiddle.net/af5g1d3q/

+0

SVG [height](https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/height)と[width](https:// developerのMDNのドキュメント.mozilla.org/ja-jp/docs/Web/SVG/Attribute/width)はなぜこれが必要であるかを説明しています。 – BSMP

関連する問題