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

前端 未结 2 1723
一整个雨季
一整个雨季 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:22

    To add to Scott's answer, dy used with em (font size units) is very useful for vertically aligning text relative to the absolute y coordinate. This is covered in the MDN dy text element example.

    Using dy=0.35em can help vertically centre text regardless of font size. It also helps if you want to rotate the centre of your text around a point described by your absolute coordinates.

    
    
    
    
    
                                     
                  
提交回复
热议问题