Skip to content
Advertisement

Fabric js – Set Canvas width and height to 100%

I am using the Fabric js 4.3.1 library and would like to be able to adapt the canvas area to its parent div #contCanvasLogo.

I’ve made a few attempts but nothing works, the canvas keeps resizing by itself. This is my code but not working:

JavaScript
JavaScript
JavaScript

Advertisement

Answer

You can set the height and width by retrieving the data from the parent container.

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement