如何设置svg宽度和svg高度百分比? [英] How to set svg width and svg height by percent?

查看:2387
本文介绍了如何设置svg宽度和svg高度百分比?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我尝试以百分比设置宽度svg,但是之后我设置了svg的宽度。这行不出现。如何以百分比设置svg的宽度

 < svg height =210width =500> 
< line x1 =380y1 =20x2 =230y2 =200style =stroke:rgb(234,243,234); stroke-width:5> ; / line>
< / svg>


解决方案

我解决了我的问题。
我改变我的代码到这,这是工作:

 < svg style =width:100%高度:100%;> 
< line x1 =100%y1 =0%x2 =0%y2 =100%style =stroke:rgb(234,243,234); stroke-width:5 ;>< / line>
< / svg>


I create a line with svg.but when I resize my browser the line created with svg not resized.

I try to set width the svg in percent but after doing that the line not appear. How I can set width of svg by percent??

<svg height="210" width="500">
  <line x1="380" y1="20" x2="230" y2="200" style="stroke: rgb(234, 243, 234); stroke-width: 5"></line>
</svg>

解决方案

I solved my problem. I change my code to this and this is working:

<svg style="width:100%;height:100%;">
  <line x1="100%" y1="0%" x2="0%" y2="100%" style="stroke: rgb(234, 243, 234);stroke-width: 5;"></line>
</svg>

这篇关于如何设置svg宽度和svg高度百分比?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆