0

i had issue with using height and width in % to take size of parent window see below link : http://liveweave.com/GZP43q

what am i missing , what to do to make it work what to do to make canvas match width of parent width , i could not find how to solve it , think bit tricky css issue

HTML CODE

<script src="http://fabricjs.com/lib/fabric.js"></script>

<div class="wrap">
<table align="center" width="100%" border="1">
<tr valign="top">
<td width="10%">
left
</td><td width="80%">
            <div id="content">
              <table border="1" width="100%">
                <tr><td style="border:1px solid red">
                    <canvas id="canvas" width="100%" height="100%">
                    </canvas>
                <div id="canvas-drop-area"></div>
                </td></tr>
              <tr><td style="border:1px solid red">
                    <canvas id="canvas1" width="320" height="256">
                    </canvas>
                <div id="canvas-drop-area1"></div>  
                </td></tr>              
            </table>
            </div>
</td><td width="10%">
right
</td></tr>
</table>
</div>

CSS CODE :

.wrap{
    margin: 0 auto;
    width: 400px;
}
#content{
    float:left;width: 100%;
}
#canvas{
    width:100%;
    height:100%;
    overflow:hidden;
    float:left;
    border:1px solid #000000;
}
#canvas1{
    width:320px;
    height:256px;
    overflow:hidden;
    float:left;
    border:1px solid #000000;
    background-color: yellow;
}
tobltobs
  • 2,782
  • 1
  • 27
  • 33
mydeve
  • 553
  • 1
  • 14
  • 39

1 Answers1

0

When you are using % in your css, then it always related to the parent height / width. So, you need to add height all of the parent elements. For content and wrap a height, and width and height to body and html.

vaso123
  • 12,347
  • 4
  • 34
  • 64