Maximum size of a element

2018-12-31 12:17发布

I'm working with a canvas element with a height of 600 to 1000 pixels and a width of several tens or hundreds of thousands of pixels. However, after a certain number of pixels (obviously unknown), the canvas no longer display shapes I draw with JS.

Does anyone know if there's a limit? Thanks.

Edit: tested both in Chrome 12 and Firefox 4.

14条回答
何处买醉
2楼-- · 2018-12-31 12:47

Even though the canvas will allow you to put height=2147483647, when you start drawing, nothing will happen

Drawing happens only when I bring the height back to 32767

查看更多
闭嘴吧你
3楼-- · 2018-12-31 12:48

According to w3 specs, the width/height interface is an unsigned long - so 0 to 4,294,967,295 (if I remember that number right -- might be off a few).

EDIT: Strangely, it says unsigned long, but it testing shows just a normal long value as the max: 2147483647. Jsfiddle - 47 works but up to 48 and it reverts back to default.

查看更多
登录 后发表回答