SVG line width issue

人走茶凉 提交于 2021-02-17 05:53:43

问题


I started my svg learning. And I want to do some skills bar with the svg line.

But there is something I didn't understand. I create 2 lines per skills (one empty, and one with the percentage of knowledge).

The problem is : The two first lines have half the height I give with stroke width. And the other lines have the good height...

here is a jsbin : http://jsbin.com/lewimonize/edit?html,css,output

Thanks in advance


回答1:


Short answer: the line is clipped in half by the view box.

When you draw a line on the y="0" axis, half of the line width is above the axis, and half is below it. Combined with the viewBox which starts at y=0, the half of the line that is above will be clipped.

You have three options:

  • Move the lines lower, so that the first one starts at y1="2.5", for example
  • Move the viewbox up: viewBox="0 -2.5 100 100"
  • Add overflow="visible" to the svg element


来源:https://stackoverflow.com/questions/37065569/svg-line-width-issue

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!