SVG height incorrectly calculated in Webkit browsers

后端 未结 9 616
轻奢々
轻奢々 2020-12-24 12:26

I have a issue specific to Webkit browsers (Safari & Chrome, on Mac & PC).

I\'m using Raphael JS to render SVG data and using a responsive layout to scale th

9条回答
  •  青春惊慌失措
    2020-12-24 12:46

    I was having a problem with Javascript returning incorrect "height" values for SVGs, and I found the solution was simply to run my script (the bit that needed to access the height) on window.load rather than document.ready.

    document.ready fires when the DOM is ready, but images have not necessarily been rendered at this point. At the point where window.load fires, images will have been loaded (and thus the browser will be able to access their dimensions correctly).

提交回复
热议问题