开发者

Raphael JS : width and height of the div and paper are different?

开发者 https://www.devze.com 2023-03-13 23:07 出处:网络
I\'m using RaphaelJS to draw an SVG. I have a div of the size 801 x 924. I create a Raphael paper with the same sizes and assign it to that div:

I'm using RaphaelJS to draw an SVG. I have a div of the size 801 x 924.

I create a Raphael paper with the same sizes and assign it to that div:

var paper = Raphael('div', 801, 924);

I expect in the browser an SVG with the size of 801 x 924 pixels. But when I check the size of the svg in the browser (with inspect element), I see that the actua开发者_如何学Gol size is 514 x 606 pixels!

The svg-element has a width and height defined as 801 x 924, but it DISPLAYS as 514x606....

Why is that? Is there some kind of DPI setting that I missed? How do I create a Raphael of the exact same size as the div ?


My mistake... I was copying paths of an existing SVG that had a VIEWBOX defined... so I thought my paths were absolute values, but in fact they were very different than what I saw in my svg-editor (Inkscape). In Raphael you don't have to define a viewbox at all, so this is were it went wrong.

0

精彩评论

暂无评论...
验证码 换一张
取 消