What is the difference between svg's x and dx attribute?

前端 未结 2 1731
一整个雨季
一整个雨季 2021-01-30 07:48

What is the difference between svg\'s x and dx attribute (or y and dy)? When would be a proper time to use the axis shift attribute (dx) versus the location attribute (x)?

2条回答
  •  庸人自扰
    2021-01-30 08:28

    x and y are absolute coordinates and dx and dy are relative coordinates (relative to the specified x and y).

    In my experience, it is not common to use dx and dy on elements (although it might be useful for coding convenience if you, for example, have some code for positioning text and then separate code for adjusting it).

    dx and dy are mostly useful when using elements nested inside a element to establish fancier multi-line text layouts.

    For more details you can check out the Text section of the SVG spec.

提交回复
热议问题