What is the default SVG unit in CSS?

2020-05-06 18:06发布

I would like to convert a transform SVG attribute into a CSS transform. Here it is:

<g transform="translate(11.225 164)"/>

But CSS requires me to specify units. What is the correct unit to specify? Since it's supposed to be a library, I don't know the width, height or viewport of the <svg>. Thus I can't compute the px or so.

1条回答
老娘就宠你
2楼-- · 2020-05-06 18:26

The default (user) unit is px.

One px unit is defined to be equal to one user unit. Thus, a length of "5px" is the same as a length of "5".

Per the SVG specification

查看更多
登录 后发表回答