Q:

Error when i try to center a canvas

I am trying to center the canvas according to the size of the browser window. I have  always implemented this css code to center my canvas but with  fabric.js it doesn't work.
Here is my css code
 canvas 
 {   
   /* Código para centrar el canvas*/
    padding-left: 0;
    padding-right: 0;
    margin-left: auto;
    margin-right: auto;
    display: block;
    width:200px;

   /*Borde y  color de fondo */
    border-radius:10px;
    background-color:rgb(170, 107, 53);
  }

html code
<canvas id="micanvas" width="200" height="200"></canvas>

javascript code
var canvas = new fabric.Canvas('micanvas');

Here's the demo

A:

It seems that FabricJS modifies the DOM of the page, so the resulting HTML source is the following (as displayed by Firebug):
<div class="canvas-container" style="width: 200px; height: 200px; position: relative; -moz-user-select: none;">
   <canvas id="micanvas" class="lower-canvas" height="200" width="200" style="position: absolute; width: 200px; height: 200px; left: 0px; top: 0px; -moz-user-select: none;"></canvas>
   <canvas class="upper-canvas " style="position: absolute; width: 200px; height: 200px; left: 0px; top: 0px; -moz-user-select: none; cursor: default;" width="200" height="200"></canvas>
</div>

So you need to center not the canvas itself, but the .canvas-container div:
.canvas-container {    
    margin-left: auto;
    margin-right: auto;
}

fiddle

